Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback with $ref is not working #879

Closed
jmini opened this issue Oct 13, 2018 · 2 comments
Closed

Callback with $ref is not working #879

jmini opened this issue Oct 13, 2018 · 2 comments

Comments

@jmini
Copy link
Contributor

jmini commented Oct 13, 2018

Consider this input file:

openapi: 3.0.0
info:
  title: Callback with ref Example
  version: 1.0.0
paths:
  /register:
    post:
      summary: Subscribe to a webhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                callbackUrl: # Callback URL
                  type: string
                  format: uri
                  example: https://myserver.com/send/callback/here
              required:
                - callbackUrl
      responses:
        '200':
          description: subscription successfully created
          content:
            application/json:
              schema:
                type: object
                description: subscription information
                required:
                  - subscriptionId
                properties:
                  subscriptionId:
                    description: unique identifier
                    type: string
                    example: 2531329f-fb09-4ef7-887e-84e648214436
      callbacks:
        myEvent:
          $ref: '#/components/callbacks/callbackEvent'
components:
  callbacks:
    callbackEvent:
      '{$request.body#/callbackUrl}':
        post:
          requestBody: # Contents of the callback message
            required: true
            content:
              application/json:
                schema:
                  type: object
                  properties:
                    message:
                      type: string
                      example: Some event happened
                  required:
                    - message
          responses:
            '200':
              description: ok

Test code:

final String inputSpec = /* path */;

OpenAPIParser openApiParser = new OpenAPIParser();
ParseOptions options = new ParseOptions();
OpenAPI openAPI = openApiParser.readLocation(inputSpec, null, options).getOpenAPI();

String ref = openAPI.getPaths()
                       .get("/register")
                       .getPost()
                       .getCallbacks()
                       .get("myEvent")
                       .get$ref();
System.out.println(ref);

ref should contain: #/components/callbacks/callbackEvent

current result is null.

Tested with:

<dependency>
  <groupId>io.swagger.parser.v3</groupId>
  <artifactId>swagger-parser</artifactId>
  <version>2.0.5</version>
</dependency>
@ymohdriz
Copy link
Contributor

Hi @jmini,

Reason for this issue is swagger-api/swagger-core#2638 which is fixed in swagger-core but not reflected in swagger-parser.

I have raised PR to fix this issue #880

Thanks,
Mohammed

@gracekarina
Copy link
Contributor

Fixed by #880

jmini added a commit to jmini/openapi-generator that referenced this issue Dec 10, 2018
jmini added a commit to OpenAPITools/openapi-generator that referenced this issue Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants