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

Allow custom schema to be specified directly in annotation #610

Open
Azquelt opened this issue May 8, 2024 · 2 comments
Open

Allow custom schema to be specified directly in annotation #610

Azquelt opened this issue May 8, 2024 · 2 comments

Comments

@Azquelt
Copy link
Member

Azquelt commented May 8, 2024

What are your thoughts on having a String value() default "" property that could be used to set an arbitrary schema (that must be valid JSON/YAML)? That would give support for alternate dialects with the annotation.

I'm not sure myself, but I wanted to mention it as a possibility.

Originally posted by @MikeEdgar in #601 (comment)

@Azquelt
Copy link
Member Author

Azquelt commented May 8, 2024

Initial thoughts

  • pros:
    • this would sidestep the problem that JSON schemas are more expressive than Java annotations
    • gives users full access to JSON schema features directly from annotations
    • allows use of custom schema dialects directly from annotations
  • cons:
    • not typesafe (unlike annotations)
    • requires familiarity with JSON schema
    • likely no IDE assistance (in contrast with writing OpenAPI or JSON schema in a standalone file)
    • need to define how this would interact with other annotation parameters or schema generated from the type
    • need to define what happens if the schema is not valid JSON/YAML

@Azquelt Azquelt added this to the MP OpenAPI 4.0 milestone May 8, 2024
@Azquelt
Copy link
Member Author

Azquelt commented May 8, 2024

I've provisionally added this to the 4.0 milestone, but we can decide not to do it and close it, or push it out of 4.0 if we're unsure or don't have time.

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

1 participant