We use Camel for our application, so I initially thought it was an issue with the Camel plugins, but here's what I've tested with Java and OAS versions:
- camel-restdsl-swagger-plugin (Java 8, Java 11, OAS v2.0)
- camel-restdsl-openapi-plugin (Java 11, OAS v3.0)
- swagger-codegen-maven-plugin (Java 11, OAS v3.0)
- Swagger Editor Demo (OAS v2.0, OAS v3.0, generate Java client)
- swagger-codegen-maven-plugin examples (Java 11, OAS v2.0)
We are building against Java 11 now, but in our previous version we used Java 8. We've tested with OAS v2.0, and I've now upgraded to OAS v3.0.
None of these attempts have worked, even though it appears they should have, based on this Github issue, implying that validation works for Java: https://github.com/swagger-api/swagger-codegen/issues/2663.
In the case of the 2 lattermost tests, I added a maximum and pattern to various attributes, built the project or generated the Java client, and saw this in one of the models (Order.java for the snip): https://pasteboard.co/JlVTLtL.png.
This same issue is mirror in our code, and our specification is valid based on the Swagger Editor. I just dropped our spec into the editor.
How do I get validation to show up? I can't paste in the entire spec, but here's an edited bit from one of our models. None of those validations are enforced in code. The max and min show up in comments, and the pattern is never mentioned.
AnExample:
description: >
The cow goes moo
type: object
properties:
id:
description: >
Uniquely identify the cow
type: string
pattern: "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[0-9a-dA-D][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000"
height:
description: >
How tall the cow is, counted in beagles
type: number
format: int64
minimum: 1
maximum: 60