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

Inconsistency for accepted keys in Component fix fields #2971

Closed
lasconic opened this issue Jul 18, 2022 · 2 comments
Closed

Inconsistency for accepted keys in Component fix fields #2971

lasconic opened this issue Jul 18, 2022 · 2 comments

Comments

@lasconic
Copy link

In the 3.1 spec one can read the following

All the fixed fields declared above are objects that MUST use keys 
that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.

However, most of the fixed fields accept a Reference Object with the key $ref which doesn't match the regular expression.

This inconsistency or lack of precision causes some tools to enforce the regular expression blindly and do not consider $ref under parameters for example as a valid OpenAPI document.
See for example : OpenAPITools/openapi-generator#11151

@hkosova
Copy link
Contributor

hkosova commented Jul 19, 2022

components:
  schemas:
    SchemaName:    # <---- It's about these keys
      ...

  parameters:
    limit:         # <----
      ...

The example from OpenAPITools/openapi-generator#11151

components:
  schemas:
    $ref: './definitions/_index.yaml'

is not valid OpenAPI syntax because $ref is not allowed directly under components.<type>, it's only allowed under components.<type>.<name>.

Some tools (such as bundlers/dereferencers) choose to support $refs in arbitrary places. In this case, you'd have to pre-process the file with the corresponding bundler/dereferencer to resolve non-standard $refs before using the file with OpenAPI-compliant tools.

@lasconic
Copy link
Author

lasconic commented Jul 19, 2022

Thank you for your answer.
OK, I reread the spec and I was mislead by

Map[string, Response Object | Reference Object]

Now I get it.

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

2 participants