-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
The default Configuration class that is used to pass in parameters to setup API security is the same name as a generated classes from the Swagger file. This class is created in the configuration.mustache template but is then used in the api.mustache template.
Swagger-codegen version
2.4.0
Swagger declaration file content or url
{
"swagger": "2.0",
"info": {
"version": "3.0.0",
"title": "Service API"
},
"host": "a.host.com",
"basePath": "/apis/3.0",
"paths":{
"/service/tickets/{id}/configurations": {
"post": {
"tags": [
"Tickets"
],
"description": "Create Configuration Association",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "id",
"type": "integer",
"format": "int32",
"in": "path",
"required": true
},
{
"name": "configuration",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ConfigurationReference"
}
}
],
}
}
},
"definitions": {
"ConfigurationReference": {
"type": "object",
"properties": {
"id": {
"format": "int32",
"type": "integer"
},
"deviceIdentifier": {
"type": "string"
},
"_info": {
"$ref": "#/definitions/Metadata",
"description": "Metadata of the entity",
"readOnly": true
}
}
}
}
}Command line used for generation
generate -i test.json -l typescript-fetch -o out/
Steps to reproduce
Generate the code and you should get warnings in the IDE about the generated class(es).
Suggest a fix/enhancement
Allow a command line option that gives you the ability to name the Configuration class to something of your choice to avoid conflict with any classes generated from your Swagger definition. If nothing is passed in, use the default class named Configuration.
But if you did something like this:
generate -i test.json -l typescript-fetch -o out/ --additional-properties apiConfigClassName=ApiConfiguration, then the generated class name would be ApiConfiguration.
This change would also use Mustache Lamda expressions to Lower and Upper case class names automatically so as to stick to standard naming conventions.
Finally, FWIW, I've already complete the core coding for this suggested change and can submit a pull request if you think there is value in this. While this change is only specific to the typescript-fetch client, it should probably be enacted across the board for all clients where the Configuration class is being automatically added. That's beyond the scope of what I need out of this at the moment, but thought I would mention it.