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

Cannot parse the openapi specification itself #523

Open
kaspermarstal opened this issue Mar 7, 2024 · 2 comments
Open

Cannot parse the openapi specification itself #523

kaspermarstal opened this issue Mar 7, 2024 · 2 comments

Comments

@kaspermarstal
Copy link

Hi, trying to parse the OpenAPI v3.1 specification itself fails with the following error message:

cargo typify ./openapi31.json
The application panicked (crashed).
Message:  not yet implemented: invalid (or unexpected) schema:
{
  "type": "object",
  "additionalProperties": {
    "$ref": "#/$defs/path-item-or-reference"
  },
  "$ref": "#/$defs/specification-extensions",
  "$comment": "https://spec.openapis.org/oas/v3.1.0#callback-object"
}
Location: /home/kasper/.cargo/registry/src/index.crates.io-6f17d22bba15001f/typify-impl-0.0.16/src/convert.rs:700

This library seems awesome. I had hoped to able to use it to work with the openapi spec in code. I don't know much about the details of the above error message however. Is this like a single bug (i.e. it should work) or is this a very complicated file (i.e. this is far off and not expected to work at the moment)?

@ahl
Copy link
Collaborator

ahl commented Mar 7, 2024

This looks to be at least a couple of bug fixes away. Proximately (i.e. the bug you hit) is that typify (incorrectly) assumes that references are going to be on their own without other data. This was true in earlier JSON Schema revisions, but is not true in more recent revisions. I think we could do a transformation effectively into this:

{
  "type": "object",
  "additionalProperties": {
    "$ref": "#/$defs/path-item-or-reference"
  },
  "allOf": [
    {
      "$ref": "#/$defs/specification-extensions"
    }
  ],
  "$comment": "https://spec.openapis.org/oas/v3.1.0#callback-object"
}

After that, I see some use of patternProperties that I don't think we're going to handle properly now (#522).

If you're thinking about making a OpenAPI 3.1 crate in the style of openapiv3 I'd be interested in hearing your thoughts. I have elaborate plans around 3.1 support... but the complexities of JSON Schema 2022-10-07 are not insignificant.

@kaspermarstal
Copy link
Author

My use-case is auto-generating PostgreSQL FDWs from OpenAPI specs. Is there anything in particular you want to me elaborate on? I am happy to share my thoughts although I know more about PostgreSQL than OpenAPI and JSON schemas.

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