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.

Referenced Responses with '../' not resolving correctly - I think

See original GitHub issue

Describe the bug I am not sure if this is a bug. But I have a schema that has numerous includes:

index.yaml

....
 /v1/foo:
    $ref: './resources/foo/paths.yaml'
....

paths.yaml

post:
...add the before
  requestBody:
    description: Details to create test
    content:
      application/json:
        schema:
          $ref: './models.yaml#/MyModel'
...add the rest
get:
...add the rest

models.yaml

MyModel:
  allOf:
    - $ref: "#/Test"
    - type: object
       properties:
         test:
           type: string

Having multiple operations in a file appears to produce an error. (I am going to investigate further.)

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Cannot read property 'content' of undefined
    at SchemaPreprocessor.extractResponseSchemaNodes (/~/project/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.preprocessor.js:306:25)
    at SchemaPreprocessor.gatherSchemaNodesFromPaths (/~/project/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.preprocessor.js:97:49)
    at SchemaPreprocessor.preProcess (/~/project/node_modules/express-openapi-validator/dist/middlewares/parsers/schema.preprocessor.js:56:24)
    at /~/project/node_modules/express-openapi-validator/dist/openapi.validator.js:81:95

Nope I extended the paths file to have 3 operations and the error resurfaced. — further update It actually looks like the resolution of the $ref pointer in the responses is not working. When I logged it,

{
  "401": { "$ref": "#/paths/~1v1~1tests/get/responses/401" }
}

My schema

responses:
    401:
      $ref: "../responses.yaml#/responses/UnauthorizedError"

— further update, I was able to continue developing by using refParser: dereference

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
golden-protocolcommented, Feb 3, 2021

Let me get you a in-depth schema. I will have time later this week.

0reactions
golden-protocolcommented, Apr 4, 2021

I checked and in the latest two bumps everything resolves correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples referenced with $ref are not rendered correctly #4924
I would like add another argument to the case for resolution. Is the current behavior for schemas. As a developer trying to define...
Read more >
15 Useful Customer Service Email Response Samples - Indeed
Learn how to properly respond to different types of customer interactions by using these customer service email response samples.
Read more >
Conflict Resolution Skills - HelpGuide.org
When handled in a respectful and positive way, conflict provides an opportunity for growth. Learn the skills that will help.
Read more >
HTTP response status codes - MDN Web Docs - Mozilla
The HTTP specification intends this status code to be used for "limited-time, promotional services". APIs should not feel compelled to indicate ...
Read more >
Clarification - Communication Skills | SkillsYouNeed
Clarifying and Clarification · “I'm not quite sure I understand what you are saying.” · “I don't feel clear about the main issue...
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