You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON Schema const on direct schema properties is silently ignored #4
When a schema property uses the JSON Schema const keyword directly, the codegen silently drops the constraint and generates a plain field with no indication of the fixed value.
const is a JSON Schema keyword (draft-06+) that OpenAPI adopted when 3.1 aligned its Schema Object with JSON Schema draft 2020-12. The codegen only recognises const inside the oneOf-of-consts enum idiom — it never reads schema.Const from a direct property schema.
This affects any OpenAPI 3.1+ spec. The reproducing example below uses 3.2 but the behaviour is identical with openapi: "3.1.0".
The const values are silently dropped. Nothing in the generated code enforces or reflects the fixed values.
What should be generated
At minimum, the constant values should be preserved as named Go constants and the fields should be initialised via something like ApplyDefaults()?. Ideally the struct gets a constructor that pre-populates them:
Activity