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

SchemaGenerator: use OpenAPI 3.0 instead of JSON Schema Draft 7 #165

Closed
wants to merge 1 commit into from

Conversation

lblasc
Copy link
Contributor

@lblasc lblasc commented Dec 30, 2024

We are using scalar, currently in browser debug console we are getting bunch of Schema errors, one example:

 {
  "_errors": [],
  "type": {
    "_errors": [
      "Expected string, received array"
    ]
  }
}

After going trough schemars docs I've noticed that there is a option to conform to openapi3 spec, additionally svix-server is already using it.

With this simple change all of the debug console errors are gone.

Let me know if I'm missing something.

@JakkuSakura
Copy link
Collaborator

Have you checked if all other doc viewers(like redoc) are compatible with OpenAPI 3.0? If not, I'd check it before merging

@lblasc
Copy link
Contributor Author

lblasc commented Dec 31, 2024

hey @JakkuSakura , thanks for looking into it.

I've tested redoc with:

  • examples/example-axum - haven't noticed any issues there, I had to fix redoc support in that example, but that is for another PR
  • https://redocly.github.io/redoc/ - loaded my api.json generated with this PR, worked fine there as with scalar
  • vendored redoc - with my api.json haven't noticed any issues, vendored redoc and scalar should be updated, but that is for another PR

Just to be clear this wasn't extensive testing, just a quick test to see if basic functionality works / shows correctly with redoc.

@tamasfe
Copy link
Owner

tamasfe commented Dec 31, 2024

aide supports openapi 3.1.*, not 3.0.*, these two are not compatible. 3.0 does not support the JSON schema spec and instead has its own schema spec based loosely on draft 5. 3.1 is fully compatible with JSON schema draft 2020-12 (which is still not draft 7 that we use, but it is compatible).

If the tools don't support openapi 3.1, you're free to change the schema generation so that it is closer to 3.0, but it is not something we should do by default.

@lblasc
Copy link
Contributor Author

lblasc commented Jan 8, 2025

@tamasfe thank you for the info, after some more digging I've discovered that this is known scalar issue, api.json generated by aide, as advertised, is 3.1 compliant, sorry for the noise.

@lblasc lblasc closed this Jan 8, 2025
@lblasc lblasc deleted the openapi3 branch January 8, 2025 16:23
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

Successfully merging this pull request may close these issues.

None yet

3 participants