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

resolveFully doesn't resolve nested references or normal references for Callbacks and its PathItem usecase #1579

Closed
mma5997 opened this issue Jun 22, 2021 · 6 comments · Fixed by #1589

Comments

@mma5997
Copy link
Contributor

mma5997 commented Jun 22, 2021

OpenAPI version : 3.0.0
Swagger-parser 2.0.26

I am using the resolveFully parse option as mentioned here but seems its not working for most of my usecases WHICH INVOLVE CALLBACKS AND PATH ITEM FOR CALLBACKS

My use case INVOLVING CALLBACKS AND ITS PATH ITEM INSIDE IT are like below

  1. Resolving nested schemas that might be referenced from "#components/schemas/"
  2. Resolving requestBody referenced from "#components/requestBodies/"
  3. Resolving response referenced from "#components/responses/"
  4. Resolving callback referenced from "#components/callbacks/"
  5. Combination of point 2,1
  6. Combination of point 3,1
  7. Combination of point 4,3,21

Looks like an issue. Technically it should resolve the local references and place it as the inline definitions in the OpenAPI document java object, if I am not mistaken reading the mentioned here. And it does resolve for other normal PathItems but for not for callbacks specific use-cases mentioned 1-7.

Please refer the below OAS3 spec :

openapi: 3.0.0
info:
  version: '1.0'
  title: simple subscription service
  description: subscription service
servers:
  - url: 'http://localhost:8085/'
paths:
  /subscriptions:
    post:
      description: creates a new subscription
      operationId: createSubscription
      parameters:
        - $ref: '#/components/parameters/key'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Subscription'
      responses:
        '201':
          $ref: '#/components/responses/SubscriptionSuccess'
        '400':
          $ref: '#/components/responses/respError'
        '500':
          $ref: '#/components/responses/respError'
      callbacks:
        notification:
          $ref: '#/components/callbacks/Notification'
components:
  callbacks:
    Notification:
      'http://localhost:8099/callback/endpoint':
        post:
          requestBody:
            $ref: '#/components/requestBodies/Notification'
          responses:
            '200':
              description: Your server returns this code if it accepts the callback
  responses:
    SubscriptionSuccess:
      description: Subscription
      headers:
        id:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Subscription'
    respError:
      description: generic response for errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Errors'
  requestBodies:
    Notification:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Notification'
      description: Notification message when event has happened
      required: true
  parameters:
    key:
      description: consumer key
      in: header
      name: API-key
      required: true
      schema:
        type: string
  schemas:
    Notification:
      type: object
      properties:
        message:
          type: string
        id:
          type: string
        sender:
          type: string
    myObject:
      type: object
      properties:
        myName:
          type: string
        myAge:
          type: integer
          format: int32
    Subscription:
      type: object
      properties:
        listOfNames:
          type: array
          items:
            $ref: '#/components/schemas/myObject'
        date:
          type: string
          format: date
        limit:
          type: integer
          format: int32
    Errors:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/Error'
    Error:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        traceId:
          type: string
        status:
          type: number

@mma5997 mma5997 changed the title resolveFully doesn't resolve nested references resolveFully doesn't resolve nested references or normal references Jun 22, 2021
@gracekarina
Copy link
Contributor

hi @mma5997, thanks for reporting this issue, please send a spec exposing exposing the issue.

@mma5997
Copy link
Contributor Author

mma5997 commented Jun 22, 2021

Hi @gracekarina , I have added a sample OAS3 spec which has most of the scenarios that I expect the resolveFully API to resolve it and place inline wherever needed and return the OpenAPI document java object when we use the OpenAPIV3Parser for reading a spec.

@mma5997
Copy link
Contributor Author

mma5997 commented Jun 25, 2021

Hi @gracekarina looks like its specific to callbacks definition that have request body, response etc references. Will confirm once and then update the issue accordingly.

vpawar-tibco added a commit to vpawar-tibco/swagger-parser that referenced this issue Jul 16, 2021
@mma5997 mma5997 changed the title resolveFully doesn't resolve nested references or normal references resolveFully doesn't resolve nested references or normal references for Callbacks and its PathItem usecase Jul 21, 2021
@mma5997
Copy link
Contributor Author

mma5997 commented Jul 21, 2021

@gracekarina ,
confirmation ==> this issue is specific to Callbacks usecase and PathItem inside it.
I have updated the issue title and the details in the body a bit.

And we also have a PR for the same... I have tested this locally and it works fine.
Thanks!

@mma5997
Copy link
Contributor Author

mma5997 commented Jul 26, 2021

@gracekarina,
Please can you let us know the release plan for this fix. It's crucial for our deliverables.
Please let me know if any concerns.
Thanks!

gracekarina added a commit that referenced this issue Jul 27, 2021
Fixed #1579 - Resolve callbacks when ResolveFully is true
@mma5997
Copy link
Contributor Author

mma5997 commented Jul 27, 2021

Thanks @vpawar-tibco @gracekarina 🙌
v2.0.28 🤞

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

Successfully merging a pull request may close this issue.

2 participants