Skip to content

Commit 65750bc

Browse files
authored
Merge branch 'master' into ci-setup-java-v2
2 parents dca2e09 + e8ff89b commit 65750bc

File tree

7 files changed

+152
-4
lines changed

7 files changed

+152
-4
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ExternalRefProcessor.java

+2
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
391391
}
392392
}
393393
newRef = possiblyConflictingDefinitionName;
394+
openAPI.getComponents().addResponses(newRef, response);
394395
cache.putRenamedRef($ref, newRef);
395396

396397
if(response != null) {
@@ -408,6 +409,7 @@ public String processRefToExternalResponse(String $ref, RefFormat refFormat) {
408409
return newRef;
409410
}
410411

412+
411413
public String processRefToExternalRequestBody(String $ref, RefFormat refFormat) {
412414
String renamedRef = cache.getRenamedRef($ref);
413415
if(renamedRef != null) {

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/OperationProcessor.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void processOperation(Operation operation) {
5151
for (String responseCode : responses.keySet()) {
5252
ApiResponse response = responses.get(responseCode);
5353
if(response != null) {
54+
//This part allows parser to put response schema inline without the resolveFully option set to true
5455
if (response.get$ref() != null) {
5556

5657
responseProcessor.processResponse(response);
@@ -63,9 +64,7 @@ public void processOperation(Operation operation) {
6364
responses.put(responseCode, resolvedResponse);
6465
}
6566
}
66-
6767
responseProcessor.processResponse(response);
68-
6968
}
7069
}
7170
}

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/processors/ResponseProcessor.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ public void processReferenceResponse(ApiResponse response){
8181
RefFormat refFormat = computeRefFormat(response.get$ref());
8282
String $ref = response.get$ref();
8383
if (isAnExternalRefFormat(refFormat)){
84-
externalRefProcessor.processRefToExternalResponse($ref, refFormat);
84+
final String newRef = externalRefProcessor.processRefToExternalResponse($ref, refFormat);
85+
86+
if (newRef != null) {
87+
response.set$ref(newRef);
88+
}
8589
}
8690
}
8791
}

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIV3ParserTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ public class OpenAPIV3ParserTest {
8383
protected int serverPort = getDynamicPort();
8484
protected WireMockServer wireMockServer;
8585

86+
@Test
87+
public void testIssue1561() {
88+
ParseOptions options = new ParseOptions();
89+
options.setResolve(true);
90+
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue-1561/swagger.yaml", null, options);
91+
OpenAPI openAPI = result.getOpenAPI();
92+
assertTrue(openAPI.getComponents().getResponses().size() == 3);
93+
}
94+
8695
@Test
8796
public void testAnonymousModelAllOf() {
8897
ParseOptions options = new ParseOptions();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
components:
2+
schemas:
3+
Exception:
4+
type: object
5+
Rfc7807Exception:
6+
description: The Rfc7807 specification for exceptions.
7+
allOf:
8+
- $ref: '#/components/schemas/Exception'
9+
- type: object
10+
properties:
11+
type:
12+
type: string
13+
description: A URI reference that identifies the problem type.
14+
required:
15+
- type
16+
- title
17+
- status
18+
- detail
19+
AbsisExceptionType:
20+
type: string
21+
enum: [VALIDATION, BUSINESS, RUNTIME, CHALLENGE, NOTFOUND, UNAUTHORIZED, AUTHENTICATION]
22+
description: The possible types of an AbsisException.
23+
AbsisFieldError:
24+
type: object
25+
description: The representation of a validation error.
26+
properties:
27+
code:
28+
type: string
29+
description: The error code.
30+
example:
31+
code: request
32+
parameters:
33+
- codes:
34+
- aCode
35+
- otherCode
36+
value: NotNull
37+
AbsisException:
38+
description: Representation of an exception.
39+
allOf:
40+
- $ref: '#/components/schemas/Rfc7807Exception'
41+
- type: object
42+
properties:
43+
_class:
44+
type: string
45+
description: The canonical name of the class AbsisException.
46+
cause:
47+
$ref: '#/components/schemas/AbsisException'
48+
description: The AbsisException wrapping the exception that originated this exception.
49+
responses:
50+
'400':
51+
description: Error when validating input parameters or request body.
52+
content:
53+
application/json:
54+
schema:
55+
$ref: '#/components/schemas/AbsisException'
56+
'404':
57+
description: The endpoint does not exists or the attempted resource does not exist.
58+
content:
59+
application/json:
60+
schema:
61+
$ref: '#/components/schemas/AbsisException'
62+
'500':
63+
description: Unexpected error occurred at one of the layers of the microservice, controller, business service, repository etc.
64+
content:
65+
application/json:
66+
schema:
67+
$ref: '#/components/schemas/AbsisException'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
openapi: 3.0.0
2+
info:
3+
description: The Trazabilidad API offers the functionalities of the new trace regardless of the channel in which it is in invoked.
4+
version: 1.0.2
5+
title: ApiTrazabilidad
6+
7+
tags:
8+
- name: Trazabilidad
9+
description: Trazabilidad API
10+
paths:
11+
'/operationalServices/tracks/scopes/{scopeId}/processes/{processId}/petitions':
12+
post:
13+
tags:
14+
- createPetition
15+
summary: Creates a new instance in the traceability operation.
16+
operationId: createPetition
17+
description: Creates a new instance in the traceability operation.
18+
parameters:
19+
- in: path
20+
name: processId
21+
description: instance process ID
22+
required: true
23+
schema:
24+
type: integer
25+
requestBody:
26+
$ref: '#/components/requestBodies/TrazabilidadBodyRequest'
27+
responses:
28+
'201':
29+
description: Created
30+
content:
31+
application/json:
32+
schema:
33+
$ref: '#/components/schemas/BodyOutResponse'
34+
'400':
35+
$ref: >-
36+
exceptions.yml#/components/responses/400
37+
'404':
38+
$ref: >-
39+
exceptions.yml#/components/responses/404
40+
'500':
41+
$ref: >-
42+
exceptions.yml#/components/responses/500
43+
44+
components:
45+
requestBodies:
46+
TrazabilidadBodyRequest:
47+
content:
48+
application/json:
49+
schema:
50+
$ref: '#/components/schemas/TrazabilidadBodyRequest'
51+
description: body request
52+
required: true
53+
schemas:
54+
BodyOutResponse:
55+
type: object
56+
properties:
57+
petitionId:
58+
type: string
59+
description: The ID of the request that has been created
60+
example: "971205125921"
61+
TrazabilidadBodyRequest:
62+
type: object
63+
properties:
64+
action:
65+
type: string
66+
description: Action to be performed. values -- alta , mod , fin , baja
67+
example: "alta"

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
<slf4j-version>1.7.30</slf4j-version>
372372
<swagger-core-version>2.1.10</swagger-core-version>
373373
<swagger-core-v2-version>1.6.2</swagger-core-v2-version>
374-
<junit-version>4.13.1</junit-version>
374+
<junit-version>4.13.2</junit-version>
375375
<testng-version>6.14.2</testng-version>
376376
<jmockit-version>1.35</jmockit-version>
377377
<wiremock-version>2.15.0</wiremock-version>

0 commit comments

Comments
 (0)