File tree Expand file tree Collapse file tree 4 files changed +70
-3
lines changed
modules/swagger-parser-v3/src
main/java/io/swagger/v3/parser/processors
java/io/swagger/v3/parser/test
resources/callbacks-issue Expand file tree Collapse file tree 4 files changed +70
-3
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,13 @@ public void processOperation(Operation operation) {
75
75
for (String name : callbacks .keySet ()) {
76
76
Callback callback = callbacks .get (name );
77
77
if (callback != null ) {
78
- if (callback .get ( " $ref" ) != null ){
79
- String $ref = callback .get ( "$ref" ). get $ref ();
78
+ if (callback .get$ref ( ) != null ){
79
+ String $ref = callback .get$ref ();
80
80
RefFormat refFormat = computeRefFormat ($ref );
81
81
if (isAnExternalRefFormat (refFormat )){
82
82
final String newRef = externalRefProcessor .processRefToExternalCallback ($ref , refFormat );
83
83
if (newRef != null ) {
84
- callback .get ( "$ref" ). set$ref (newRef );
84
+ callback .set$ref (newRef );
85
85
}
86
86
}
87
87
}
Original file line number Diff line number Diff line change @@ -66,6 +66,17 @@ public class OpenAPIV3ParserTest {
66
66
protected int serverPort = getDynamicPort ();
67
67
protected WireMockServer wireMockServer ;
68
68
69
+ @ Test
70
+ public void testIssueResolveCallBacks () {
71
+ ParseOptions options = new ParseOptions ();
72
+ options .setResolve (true );
73
+ options .setFlatten (true );
74
+ SwaggerParseResult parseResult = new OpenAPIV3Parser ().readLocation ("callbacks-issue/swagger.yaml" , null , options );
75
+ OpenAPI spec = parseResult .getOpenAPI ();
76
+ assertNotNull (spec );
77
+ assertEquals (spec .getPaths ().get ("/webhook" ).getPost ().getCallbacks ().get ("WebhookVerificationEvent" ).get$ref (),"#/components/callbacks/WebhookVerificationEvent" );
78
+ }
79
+
69
80
@ Test
70
81
public void testIssue1190 () {
71
82
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser ();
Original file line number Diff line number Diff line change
1
+ # OpenAPI version identifier - required for OpenAPI 3.0 domains
2
+ openapi : 3.0.0
3
+
4
+ # ######################
5
+ # Optional info section
6
+ # ######################
7
+ info :
8
+ title : Common
9
+ description : Common Components for REST API's
10
+ version : ' 1.0.1'
11
+
12
+ components :
13
+
14
+ # ########################
15
+ # Common callback definitions
16
+ # See: https://swagger.io/docs/specification/callbacks/
17
+ # ########################
18
+ callbacks :
19
+ # ### Webhooks ####
20
+ WebhookVerificationEvent :
21
+ ' https://yourdomain.com/css/yourCallbackEndpoint ' :
22
+ post :
23
+ parameters :
24
+ - $ref : ' #/components/parameters/x-api-key'
25
+ requestBody :
26
+ required : true
27
+ description : description
28
+ content :
29
+ application/json :
30
+ schema :
31
+ $ref : ' #/components/schemas/WebhookVerification'
32
+ responses :
33
+ ' 202 ' :
34
+ description : Your server returns this code if it accepts the message it was sent
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.2
2
+ servers :
3
+ - description : Dev server
4
+ url : ' https://api.net'
5
+ info :
6
+ title : API
7
+ version : 1.0.0
8
+ description :
9
+ tags :
10
+ - name : Webhook API
11
+ description : Endpoints related to the subscription and management of Webhooks
12
+ paths :
13
+ ' /webhook ' :
14
+ post :
15
+ tags :
16
+ - Webhook API
17
+ summary : Subscribe to events for a Market Participant
18
+ description : description
19
+ operationId : subscribe-webhook
20
+ callbacks :
21
+ WebhookVerificationEvent :
22
+ $ref : ' domain.yaml#/components/callbacks/WebhookVerificationEvent'
You can’t perform that action at this time.
0 commit comments