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

Validation failure with relative references to another files #2

Closed
javier-sierra-sngular opened this issue Jan 17, 2024 · 1 comment · Fixed by #3
Closed

Validation failure with relative references to another files #2

javier-sierra-sngular opened this issue Jan 17, 2024 · 1 comment · Fixed by #3
Assignees
Labels
bug Something isn't working

Comments

@javier-sierra-sngular
Copy link

When an OpenAPI document contains a relative schema reference pointing to another file, causes validate() function failure.

This is a simple schema example to reproduce:

openapi: '3.0.0'
info:
  version: 1.0.0
  title: OpenAPI simple test.
  license:
    name: MPL-2.0

paths:
  /:
    get:
      summary: test
      description: test
      operationId: test
      responses:
        '200':
          description: test
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: './components/schemas/test.yml'

The problem starts in the constructor when LocalSchemaLoader is executed. This class uses js-yaml that loads the yaml and convert it to a JSON, but it does not resolve the internal references.
So when SwaggerParser.validate try to do a dereference cannot find the files, because the relative paths are being resolved with the path of the execution program and not the path of the principal yaml file parsed partially in the constructor.

@javier-sierra-sngular javier-sierra-sngular added the bug Something isn't working label Jan 17, 2024
@javier-sierra-sngular javier-sierra-sngular self-assigned this Jan 17, 2024
Copy link

Thank you for collaborating with the project by giving us feedback!

javier-sierra-sngular added a commit that referenced this issue Jan 17, 2024
@javier-sierra-sngular javier-sierra-sngular linked a pull request Jan 17, 2024 that will close this issue
javier-sierra-sngular added a commit that referenced this issue Jan 17, 2024
jorgecasar pushed a commit that referenced this issue Jan 18, 2024
sngularbot pushed a commit that referenced this issue Jan 18, 2024
## [1.0.1](v1.0.0...v1.0.1) (2024-01-18)

### Bug Fixes

* remove LocalSchemaLoader ([85d684f](85d684f)), closes [#2](#2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant