Skip to content

Is there a way to inline enums? #176

Closed Answered by CarstenWickner
electrosaur asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @electrosaur,

Is the Option.FLATTENED_ENUMS fulfilling your requirement?

As per https://victools.github.io/jsonschema-generator/#generator-options

5 - Option.FLATTENED_ENUMS

Behaviour if included:

  • Treating enountered enum types as { "type": "string" } schema with the names of the enum constants being listed as its enum values.

That should produce something like this:

{
  "type": "object",
  "properties": {
    "y": {
      "type": "string",
      "enum": ["HOURS", "DAYS", ...]
    }
  }
}

If you want to generally avoid that enums are being referenced via the $defs/definitions, then please refer to my answer on this issue: #123

to inline all enums you can use configBuilder.forType…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by electrosaur
Comment options

You must be logged in to vote
1 reply
@CarstenWickner
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants