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

OpenAPI type validation #204

Closed
MathNerd28 opened this issue Nov 12, 2023 · 1 comment
Closed

OpenAPI type validation #204

MathNerd28 opened this issue Nov 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@MathNerd28
Copy link

Support for OpenAPI 3.0/3.1 type validation (see here) as annotations rather than custom properties.

Something like this (Java):

@OpenApiNumberValidation(minimum = 1, maximum = 9999)
int count

@OpenApiStringValidation(maxLength = 32, pattern = "[\\w\\s]+")
String name

Would produce this:

"count" : {
    "type" : "integer",
    "format" : "int32",
    "minimum": 1,
    "maximum": 9999
},
"username" : {
    "type" : "string",
    "maxLength": 32,
    "pattern": "[\\w\\s]+"
}
@dzikoysk dzikoysk added the enhancement New feature or request label Nov 12, 2023
@dzikoysk
Copy link
Member

dzikoysk commented Nov 12, 2023

I guess it makes sense. Keep in mind that you can still do that with @Custom:

@Custom("pattern", "[\\w\\s]+")
String name

or even custom annotation:

@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
@Retention(RUNTIME)
@CustomAnnotation
annotation class OpenApiNumberValidation(
    val minimum: Int,
    val maximum: Int
)

@dzikoysk dzikoysk moved this from 🆕 New to 📋 Backlog in Javalin OpenApi Jan 30, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Javalin OpenApi Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

2 participants