You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
I'm trying to use swagger-codegen to generate a Python client from my django-rest-swagger schema (django-rest-swagger==2.0.7, djangorestframework==3.5.3).
I am getting a lot of models named Data*, and no client models related to my actual API models.
Note the "in": "body", "name": "data" in the generated swagger JSON.
The model generated by swagger-codegen has the correct fields, but incorrect name:
class Data1(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self, account_number=None, ...):
"""
Data1 - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
'account_number': 'str',
...
}
...
Per the swagger-codegen client, it's expected that the "name" field here should actually describe the resource.
Yup I think this is pretty valid point. We don't properly name the field in those cases because we don't have a serializer field on which to base that name. However, using the serializer class name or similar as a more meaningful name would make a lot of sense.
I'm working through all the Core API integration in detail at the moment as part of introducing a live-documentation tool for REST framework, so addressing this is absolutely on my backlog right now.
Reacted by Paul Tiplady, Jeff Bowman, Lee Skillen and Dan Fellin
Hi! Any update on when this issue plans on being addressed? This issue is a blocker for my project. I am using autorest to create a C# client, (it simply uses the last model with same name (e.g. 'Data')) So of course this makes my client completely useless.
I needed a temporary solution, so I made the two pull requests above. They enable a user to specify a "title" field on the view (or viewset) which will then be used to generate a custom name on the swagger JSON (instead of "data").
Activity
lovelydinosaur commentedon Dec 15, 2016
Yup I think this is pretty valid point. We don't properly name the field in those cases because we don't have a serializer field on which to base that name. However, using the serializer class name or similar as a more meaningful name would make a lot of sense.
I'm working through all the Core API integration in detail at the moment as part of introducing a live-documentation tool for REST framework, so addressing this is absolutely on my backlog right now.
jmbowman1107 commentedon Jan 14, 2017
Hi! Any update on when this issue plans on being addressed? This issue is a blocker for my project. I am using autorest to create a C# client, (it simply uses the last model with same name (e.g. 'Data')) So of course this makes my client completely useless.
lovelydinosaur commentedon Jan 15, 2017
Noted. It's possible that it'll be resolved as part of the 3.6 release (planned for Feb/Mar)
wrsulliv commentedon Apr 2, 2017
Hey! Any further updates on this issue? I'm also looking to use swagger-codegen with descriptive model names (instead of "DataX").
Use the "title" and "action" properties of the Link object to set the…
Pass the the "title" attribute from each view when constructing Link …
wrsulliv commentedon Jul 18, 2017
I needed a temporary solution, so I made the two pull requests above. They enable a user to specify a "title" field on the view (or viewset) which will then be used to generate a custom name on the swagger JSON (instead of "data").