Giter Club home page Giter Club logo

Comments (11)

wajahatahmed245 avatar wajahatahmed245 commented on June 22, 2024 3

I want to request data in form data not in JSON how can I change that in yasg ? by default it is json form I want it to be in form data form @axnsan12
image

from drf-yasg.

axnsan12 avatar axnsan12 commented on June 22, 2024

Hello,

I am sorry but I do not really understand your question. The data node is the request body. It is what is sent in the body part of a POST/PUt/PATCH request.

You can get rid of it by not using request_body...

from drf-yasg.

andrenerd avatar andrenerd commented on June 22, 2024

it's ok, if it should be like that (please, close the issue in the case).

PS.
previously when i created swagger docs manually, all the body params are displayed without "data" node in the doc.

from drf-yasg.

andrenerd avatar andrenerd commented on June 22, 2024

...and old rdf swagger doc generators do it the same "no data" way:

screen shot 2018-01-15 at 16 20 09

from drf-yasg.

axnsan12 avatar axnsan12 commented on June 22, 2024

It seems to me that those are form parameters, not JSON body parameters. You will find that this library generates the same format for form requests (i.e. if your remove json renderers/parsers from the view).

However you will also find that form parameters do not support nesting, and the library your are referencing above would probably incorrectly represent any nested serializers in the request body as a plain string value.

from drf-yasg.

axnsan12 avatar axnsan12 commented on June 22, 2024

You might find this an interesting read; http://drf-yasg.readthedocs.io/en/stable/custom_spec.html#swagger-spec-overview

Specifically the part about Schema vs Parameter.

from drf-yasg.

axnsan12 avatar axnsan12 commented on June 22, 2024

Maybe an option to prefer form parameters could be useful for cases where there is no nesting?

from drf-yasg.

andrenerd avatar andrenerd commented on June 22, 2024

@axnsan12
thanks.
it works well when DEFAULT_PARSER_CLASSES is set to FormParser/MultiPartParser.

from drf-yasg.

axnsan12 avatar axnsan12 commented on June 22, 2024

Glad it worked out for you!

from drf-yasg.

hedleyroos avatar hedleyroos commented on June 22, 2024

@axnsan12 thread necromancy, but related to your earlier comment. I found a way to make form parameters support nesting. Is there a place to contribute this as a recipe?

from drf-yasg.

bay007 avatar bay007 commented on June 22, 2024

https://drf-yasg.readthedocs.io/en/stable/custom_spec.html#swagger-spec-overview

  • request_body
    @swagger_auto_schema(methods=['put', 'post'], request_body=UserSerializer)

from drf-yasg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.