Support multiple request bodies
Hi! Thanks for the generator 🙌 Compared to openapi-generator typescript-fetch, it has clean and understandable output 👏
Any thoughts on supporting multiple request bodies?
I'm trying to generate a client for the kubernetes API, which has "patch" endpoints with multiple possible request bodies.
For example the ConfigMap resource:
curl --silent https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/v3/api__v1_openapi.json \
| jq '.paths["/api/v1/namespaces/{namespace}/configmaps/{name}"].patch.requestBody.content'
{
"application/apply-patch+yaml": {
"schema": {
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
}
},
"application/json-patch+json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
}
},
"application/merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
}
},
"application/strategic-merge-patch+json": {
"schema": {
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.Patch"
}
}
}
By default, I get application/json-patch+json in the generated client. Also, the patch method has no overrideOptions to controll the content-type.
A workaround could be creating a named client, then setting the override options there, but content-type is hardcoded to use options.mediaType in getHeaders. That should probably be easy to fix, by adjusting the templates.
I could also adjust templates to take an extra overrideOptions parameter.
Ideally, I would like multiple methods, one per request body, where the body type varies between them. (Currently object body type in schema for all request bodies, but that's solvable from the schema.)
Anyhow, any thoughts on supporting multiple request bodies? Maybe you already have given it a thought?
Would love this too 👍