django-rest-swagger icon indicating copy to clipboard operation
django-rest-swagger copied to clipboard

More details about request parameters

Open tsudmi opened this issue 7 years ago • 12 comments

Currently, it is really hard to understand what value the parameter must have. Please make it possible to specify more details about request parameters. It should be possible to specify at least custom Data Type and parameter possible values.

For example, screen shot 2017-02-07 at 16 15 41

Source: http://petstore.swagger.io/#!/pet/findPetsByTags

tsudmi avatar Feb 07 '17 14:02 tsudmi

I'm facing the same problem here. I can't seem to add any more information to the docs, everything is autogenerated, and the YAML docstrings are depreciated.

gamesbrainiac avatar Feb 13 '17 13:02 gamesbrainiac

Same here. I would love to be able to add info to the description field

VidJa avatar Apr 05 '17 15:04 VidJa

@gamesbrainiac yes YAML docstrings are deprecated but you can override the SchemaGenerator Class for your own use, as here: https://github.com/m-haziq/django-rest-swagger-docs#advance-usage

m-haziq avatar Nov 13 '17 06:11 m-haziq

Hi @m-haziq , good docs, do you have some examples to use django-rest-swagger without any models or database? In my case, I am creating some API which integrated with several restful API together and add some logic inside. I cannot find any doc explains without models , serialization

changsijay avatar Jun 12 '18 07:06 changsijay

Hi @changsijay, thanks for appreciation. Yes definitely you can use it without models , as explained in my docs here: https://github.com/m-haziq/django-rest-swagger-docs#advance-usage No need of models/serialization. Use YAML to describe params. P.S: Sorry for late reply, I was on vacations!

m-haziq avatar Jun 19 '18 18:06 m-haziq

@m-haziq Hello, I have tried your solution but It is not working in django-rest-swagger 2.2.0 version for describing parameters and all.So is there any solution for v2.2.0 ?

dhaval455 avatar May 27 '19 06:05 dhaval455

The solution I shared above can be used only with: djangorestframework==3.5.3 django-rest-swagger==2.1.1 in case of "function based views". But if you are using class based views, then you should be able to use this solution normally. What is your case?

m-haziq avatar May 27 '19 07:05 m-haziq

I have tried in both function based view and class based view. But it is not working.

dhaval455 avatar May 27 '19 08:05 dhaval455

In class based view, it is quite simple, as mentioned in official documentation. You have to write serializer and it will show parameters according to serializer class. Please share the specific error you are getting, so that I may be able to help more.

m-haziq avatar May 27 '19 12:05 m-haziq

Thanks for replying @m-haziq I am not getting any error. It does not show parameter in swagger UI as per your solution. Do you have example or link for your above suggestion(serializer class)? Please share so that I can refer.

dhaval455 avatar May 27 '19 13:05 dhaval455

Yes you can clone this repo: https://github.com/m-haziq/django-rest-swagger-docs By installing requirements, you can run the project and see inside cbv_demo how class based views are documented.

m-haziq avatar May 27 '19 13:05 m-haziq

@m-haziq In above link there is not any cbv_demo. I have already clone https://github.com/marcgibbons/django-rest-swagger repo and also checked the all files of it. But I did not find the code to describing parameters. And In my django rest api there is not any model.

dhaval455 avatar May 28 '19 05:05 dhaval455