-
-
Notifications
You must be signed in to change notification settings - Fork 262
Description
I have an OpenAPI spec that has two endpoints with the same operationId ("raw-data"). Their paths are ".../node3/raw-data" and ".../node4/raw-data". The generator doesn't create a model for the Node 3 200 response, because of a name collision with the Node 4 200 response.
What I want is a a config option to resolve this issue.
As a suggestion, the option could be to include the first tag in the class name to create unique model class names. The grouping within the "api" module into separate folders based on the first tag ("node3/raw_data.py" and "node4/raw_data.py", respectively) prevents name collisions there. I want something similar for the models.
Using "class_override" in the config doesn't work, because both of the RawDataResponse200 model classes are renamed and the issue persists.
What I'm doing currently is manually editing my OpenAPI spec before running the generator. I don't have any detailed control of how my OpenAPI spec is generated, it comes from a third party program. It would be great to not have to do this manually, since the generator output becomes inconsistent (suddenly there's an endpoint method in the client library with a name different from the API endpoint) and it's harder to maintain.
Here is the relevant warning message:
Warning(s) encountered while generating. Client was generated, but some pieces may be missing
WARNING parsing GET /v0/node3/raw-data within node3.
Cannot parse response for status code 200 (Attempted to generate duplicate models with name "RawDataResponse200"), response will be ommitted from generated client
Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=None, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties={'node3.raw-dataResponse': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.OBJECT: 'object'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties={'node3.VARCHAR': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.STRING: 'string'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties=None, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None), 'node3.raw-dataResult': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.OBJECT: 'object'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties={'node3.row': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.ARRAY: 'array'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.OBJECT: 'object'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties={'node3.datetime': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.STRING: 'string'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties=None, additionalProperties=None, description=None, schema_format='date-time', default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None), 'node3.value': Schema(title=None, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, maxLength=None, minLength=None, pattern=None, maxItems=None, minItems=None, uniqueItems=None, maxProperties=None, minProperties=None, required=None, enum=None, type=<DataType.NUMBER: 'number'>, allOf=[], oneOf=[], anyOf=[], schema_not=None, items=None, properties=None, additionalProperties=None, description=None, schema_format='float', default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)}, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None), properties=None, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)}, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)}, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)}, additionalProperties=None, description=None, schema_format=None, default=None, nullable=False, discriminator=None, readOnly=None, writeOnly=None, xml=None, externalDocs=None, example=None, deprecated=None)
If you believe this was a mistake or this tool is missing a feature you need, please open an issue at https://github.com/openapi-generators/openapi-python-client/issues/new/choose
and here are the relevant parts of my OpenAPI spec that can be used to recreate the issue
{
"openapi": "3.0.1",
"info": {
"title": "redacted",
"description": "redacted",
"version": "redacted"
},
"servers": [
{
"url": "https://example.com",
"description": "redacted"
}
],
"tags": [
{
"name": "node4"
},
{
"name": "node3"
}
],
"paths": {
"/v0/node4/raw-data": {
"get": {
"tags": [
"node4"
],
"summary": "raw-data",
"description": "",
"operationId": "raw-data",
"parameters": [
{
"name": "i_bucket",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "i_range",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "i_measurement",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "i_filter",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"properties": {
"node4.raw-dataResponse": {
"type": "object",
"properties": {
"node4.VARCHAR": {
"type": "string"
},
"node4.raw-dataResult": {
"type": "object",
"properties": {
"node4.row": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node4.datetime": {
"type": "string",
"format": "date-time"
},
"node4.value": {
"type": "string"
},
"node4.field": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
},
"/v0/node3/raw-data": {
"get": {
"tags": [
"node3"
],
"summary": "raw-data",
"description": "",
"operationId": "raw-data",
"parameters": [
{
"name": "i_measurement",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "i_from",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "i_to",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"properties": {
"node3.raw-dataResponse": {
"type": "object",
"properties": {
"node3.VARCHAR": {
"type": "string"
},
"node3.raw-dataResult": {
"type": "object",
"properties": {
"node3.row": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node3.datetime": {
"type": "string",
"format": "date-time"
},
"node3.value": {
"type": "number",
"format": "float"
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}