Add raw openapi schema to typescript client #279
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ref: kubernetes-client/javascript#2384
This PR adds the original raw openapi schema to the generated typescript models. This is required to include the Kubernetes specific extension
x-kubernetes-group-version-kind
that includes the group version and kind of the resource.Only adding that field is not possible because the
modelJson
variable is a raw string that I was unable to correctly parse with mustache (the templating engine used by the openapi generator).In order to use a dedicated template, the template was added to a new subfolder of the structure
openapi/templates/$CLIENT_TYPE
. That subfolder is automtically mounted to the generator container at/template
if it is defined.Doing it like makes it easy for other language to add templates in the future if required.
The newly generated modals look like this example of a
Secret
resource:the formatting of the
OPENAPI_SCHEMA
is a bit broken because indentation is not possible via mustache.An alternative would be to have the schema in a variable for readability. But not sure if this is worth adding on a anyway generated file.
e.g.