Open creativecreature opened 1 year ago
This would be useful for our use-case as well. The title
property of inlined schemas can be used to determine the model name.
eg:
"responses": {
"200": {
"description": "GET /v1/examples Returns all examples",
"content": {
"application/json": {
"schema": {
"title": "InlineModel"
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
...
Describe the bug It does not generate models for schemas that are defined within the paths object:
The models are only generated if the schemas are moved into
components/schemas
at the bottom of the file.Would it be possible to modify the
getModels
function so that it traverses the paths and looks for schemas there too? Right now it only looks for schemas withincomponents/schemas
andcomponents/parameters
: https://github.com/ferdikoomen/openapi-typescript-codegen/blob/master/src/openApi/v3/parser/getModels.ts#L9The services that we are able to generate with this library can extract types from the schemas that are defined within the paths. This makes me hopeful that most of the code to achieve this could exist within this project already.
I guess the tricky part would be to figure out what these models should be named.