swagger-api / swagger-api/swagger-codegen
Generate unserviceable swagger server code while object include object define
@HugoMario is already working on this.
Since May 8, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
After I suggessfully generate the swagger server code for python-flask, the code cannot be run. The root cause is the generated code by swagger include a wrong class name.
Yaml:
clusterStatsResultType:
type: object
properties:
hwMetrics:
type: object
properties:
metricsNum:
type: number
description: how many metrics to be record such as cpu, gpu and memory, and then, the value is 3
metricsList:
type: array
description: it shall be current value such as current cpu number, or memory size, gpu number, node number and total job number
items:
$ref: '#/definitions/keyValuePair'
The generated code as:
class ClusterStatsResultType(Model):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, hw_metrics: ClusterStatsResultTypeHwMetrics=None, user_metrics: List[UserResourceType]=None): # noqa: E501
"""ClusterStatsResultType - a model defined in Swagger
:param hw_metrics: The hw_metrics of this ClusterStatsResultType. # noqa: E501
:type hw_metrics: ClusterStatsResultTypeHwMetrics
:param user_metrics: The user_metrics of this ClusterStatsResultType. # noqa: E501
:type user_metrics: List[UserResourceType]
"""
self.swagger_types = {
'hw_metrics': ClusterStatsResultTypeHwMetrics,
'user_metrics': List[UserResourceType]
}
There are two issues:
- ClusterStatsResultTypeHwMetrics is not right object name and there is no any HwMetrics related define generated
- UserResourceType object has been generated. But not correctly imported in the model file.
Swagger-codegen version
I run the generate from Swagger web server.
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.