We have an OpenAPI 3.x YAML file loading variable definitions from a JSON Schema. These definitions come from a standard: we cannot change their constant values nor the way they are dispatched into enums.

But sometimes constant values repeat themselves:

"SizePrecision": {
  "enum": [
     "Centimetre",
     "Metre"
   ]
},
"DistancePrecision": {
  "enum": [
     "Centimetre",
     "Kilometre",
     "Metre",
     "Millimetre"
   ]
}

When we generate client code from a 3.x OpenAPI YAML file,
depending on which tool we are using for that, we are experiencing that:

  • all the generated types or classes are going to the same package (for example: openapiclient)
  • OpenAPI Generator will generate conflicting variables of same name, holding these constants CENTIMETRE, METRE, each variable name being defined two times, with the same name. It produces a code that isn't compilable.
  • quicktype will rename two of of these variables holding a constant value in DistancePrecisionCentimetre, DistancePrecisionMetre.

But the overall is not really predictable, and because we don't know what tool will use a customer to generate its client stub from our YAML file, it's not steady.


I know that from the OpenAPI Generator command line,
it's possible to change the name of the package where the model will be generated.
But it's for all the model classes or types generated then. So it won't change the issue.

Is there a way, through the OpenAPI YAML spec,
to ask some of the model types or classes to be generated in a different package than others?

Or, through the OpenAPI Generator command line, a way to achieve this?

0

There are 0 best solutions below