question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mma5997commented, 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.

0reactions
mma5997commented, Jul 27, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

resolveFully doesn't resolve nested references or normal ...
Actually, the Callbacks PathItem related members were not getting resolved using the resolveFully ParseOptions that we set as shown in code snippet.
Read more >
How to deal with nested callbacks and avoid “callback hell”
It's mind-boggling to see nested callbacks, but I don't think it's a “hell”. The “hell” can be manageable if you know what to...
Read more >
Understanding the Event Loop, Callbacks, Promises, and ...
This section will explain how JavaScript handles asynchronous code with the event loop. It will first run through a demonstration of the event ......
Read more >
JavaScript Callbacks Variable Scope Problem - Pluralsight
In this free JavaScript guide, you'll learn how to fix the common JavaScript callbacks variable scope problem. This step-by-step JavaScript ...
Read more >
Rewriting nested callbacks with Promises and async/await ...
It's an old-fashioned JS code that illustrates the common struggle with nested callbacks in rl.question method calls. Here arrow function is used in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found