swagger-api / swagger-api/swagger-codegen
[go][python] Fail to generate python code from a empty go struct
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Fail to generate python code from a empty go struct
dump empty go struct successfully create the configuration for the json file but generate the python code configure the reference but dont create the related model
Swagger-codegen version
2.2.3
Swagger declaration file content or url
go struct
type InterfaceBindingMethod struct {
Bridge *InterfaceBridge `json:"bridge,omitempty"`
Slirp *InterfaceSlirp `json:"slirp,omitempty"`
}
// ---
// +k8s:openapi-gen=true
type InterfaceBridge struct{}
// ---
// +k8s:openapi-gen=true
type InterfaceSlirp struct {
// List of ports to be forwarded to the virtual machine.
Ports []Port `json:"ports,omitempty"`
}
generated json relevant part
"v1.Interface": {
"required": [
"name"
],
"properties": {
"bridge": {
"$ref": "#/definitions/v1.InterfaceBridge"
},
"model": {
"description": "Interface model.\nOne of: e1000, e1000e, ne2k_pci, pcnet, rtl8139, virtio.\nDefaults to virtio.",
"type": "string"
},
"name": {
"description": "Logical name of the interface as well as a reference to the associated networks.\nMust match the Name of a Network.",
"type": "string"
},
"slirp": {
"$ref": "#/definitions/v1.InterfaceSlirp"
}
}
},
"v1.InterfaceBridge": {},
"v1.InterfaceSlirp": {
"properties": {
"ports": {
"description": "List of ports to be forwarded to the virtual machine.",
"type": "array",
"items": {
"$ref": "#/definitions/v1.Port"
}
}
}
}
generated python code
class V1Interface(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'bridge': 'V1InterfaceBridge',
'model': 'str',
'name': 'str',
'slirp': 'V1InterfaceSlirp'
}
attribute_map = {
'bridge': 'bridge',
'model': 'model',
'name': 'name',
'slirp': 'slirp'
}
the v1_interface_bridge.py file not exist.
Command line used for generation
java -jar swagger-codegen-cli.jar generate
-i swagger.json
-l python
-o /out/ &>/out/pysdk-codegen.log
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.
Research direction
Reproduce the report with the shown Go structs and swagger.json using swagger-codegen 2.2.3 and the Python generator. Inspect the generated v1_interface_bridge.py output alongside the empty v1.InterfaceBridge definition in the generated JSON. Done means the empty model is generated while its reference remains usable in the Python client.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100