Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Jun 30 16:25
    Bxmnx opened #451
  • Jun 30 13:23
    mh4x0f commented #160
  • Jun 30 12:59
    dhanababum commented #360
  • Jun 29 08:22
    lvhao54 commented #421
  • Jun 29 06:58
    TreeKat71 opened #450
  • Jun 27 13:25
    ikornaselur commented #263
  • Jun 21 14:52
    MajorDallas commented #59
  • Jun 21 14:50
    MajorDallas commented #59
  • Jun 21 14:31
    deamos commented #422
  • Jun 15 02:52
    hnakamitsu commented #449
  • Jun 15 02:39
    hnakamitsu labeled #449
  • Jun 15 02:39
    hnakamitsu opened #449
  • Jun 15 01:26
    nickshanks347 edited #448
  • Jun 15 01:22
    nickshanks347 opened #448
  • Jun 15 01:22
    nickshanks347 labeled #448
  • Jun 14 19:35
    thedumbterminal commented #441
  • Jun 14 12:52
    radiantone edited #447
  • Jun 14 12:39
    radiantone labeled #447
  • Jun 14 12:39
    radiantone opened #447
  • Jun 14 05:57
    ntatsumi edited #446
Abdur-Rahmaan Janhangeer
If anybody is up for a talk about restx would be awesome: https://flaskcon.com/y/2021/
People need to discover the framework more!
Hey all :) I have a quick question I couldn't find the answer to. I'm looking for a way to use api.doc() to document a POST request which should be able to take any JSON body (that is to say a valid JSON body is required, doesn't matter what is actually inside that body). At the moment, I am using a reqparse that is passed to the api.expect() which I dont actually use in my code but is just there to force the Swagger docs to give me a JSON body when clicking "Try it out". I understand there isn't really a way to pass custom Swagger JSON (as you would be able to pass invalid JSON) so what would be the best way to do this?
Hi, how do I change the default response content type in swagger ui. I tried ns.produces and api.representation. I woul dlike to replace application/json to application/xml
Brock Palen
Is there a way when marsharling a response to not display a field if it's null / None? I have a single code base that has nested models, and some systems don't have a given feature so rather than returning null the front end people prefer we not pass along something that doesn't exist at all on that system.
Harshal Chaudhari
@brockpalen I remember vaguely there is an option to skip none fields during marshalling. You will have to check the fields.raw and other classes used for marshalling. Alternatively, you could override the output function of any fields class and change the output to suit your needs
Brock Palen
@harshalchaudhari35 Looks like there is a mask= option that is a callable, I'll try that and report.
Harshal Chaudhari
@brockpalen here this is what I have referring to earlier
Brock Palen
@harshalchaudhari35 skip_none= is what I wanted actually, and it works perfectly becaus depending on configuration different values in the nested group are populated. In our case does our campus HPC cluster have single precision GPUs or not,
Turns out mask= does something I hacked around by having a nasty lambda function in my model so that will clean that up significantly,
Really appreciate it, I need to get in the habbit of looking at the prototypes and not just the normal example documentation,
Harshal Chaudhari
@brockpalen glad that helped and worked out for you. Yeah my experience has been the same and daunting with restx. Many times I find myself overriding many functions from the library.
Brock Palen
NP, I really like the library, just wish it had more community behind it, it front ends out 14,000 CPU HPC cluster, and will soon front end our 20PB research archive, our univeristy really appreciates such an easy to understand library is available,
Brock Palen
Maybe I'm not grocking it, but how do I input validation when for POST requests @api.route("/<string:subaccount>/user/<string:uniquename>") How do I do stricter validation of uniquename much like parsing payloads? Do I do it all manually in my routine? Or is there something more strict than <string:varname> ?
Harshal Chaudhari
Ah what you are looking for is more of base flask functionality here. Flask provides a set of converters types to validate/typecast the route params. You can create your own converter types as mentioned here. https://uniwebsidad.com/libros/explore-flask/chapter-6/url-converters
If you don't want to define your own stuff and prefer a library doing it for you heres one https://github.com/Ge0rg3/flask-parameter-validation seems to support whitelists and regex validation
Brock Palen
Thanks i'll check that out
Brock Palen
BTW do POST requests have to have a payload if all the values in the model are optional? I found my unit tests fail unless I send an empty payload.
Harshal Chaudhari
Short answer is yes :) You could get away with using content-length header set to 0 also
Brock Palen
Weird, then why do I get a 500 rc if I don't pass data=json.dumps({})
Ryan Truran
OAS3 allows for one response to have multiple schemas, through the use of oneOf, anyOf, allOf, not.
Does restx currently support this?
Matthew Jacobsen
Can anyone offer some live support right now? I am having trouble with my routing. Keep getting 404 when routing to my API Blueprint, but the regular flask routes are getting reached just fine
Jamin Collins
I'm having a bit of trouble with RequestParser and how to specify that an argument is a list of strings. From what I can find, action="append" should do it, but adding this appears to drop the element from the generated Swagger documentation.
Brock Palen
Is there a flask library to generally protect against URL injection through routes? The flask security page didn't have anything that stuck out,
@j5awry @ziirish Any ETA for the next bugfix release?
Giacomo Gritzan

I currently have problems with marshalling my Responses.

I am trying to do the following:

test_model = Model(
        "_id": fields.String,
        "name": fields.String,
        "location": fields.String,
        "ip": fields.String,

success_model = Model(
    {"data": fields.List(

Without throwing any exception the data in the response is null

[{"status": "success", "data": null}']
Can somebody give me an advice?

Patrick Ray. Huang
hello all, I am new to restx, wondering when creating a model that has a one to many relationship, (e.g, order and order_items), how do i specify the field in the order model?
Tiago Tavares
Could enable the creation of models without automatically documenting, please?
It would be great to use @api.marshal_with(model) with multiple models, but not letting all of them be documented in swagger
John Chittum
FYI: i'm no longer a maintainer of python-restx. @ziirish is the final member left. I've removed my privs from Github. unfortunately, I have no time. and, honestly, i've started receiving personal emails asking about merges, etc. I don't have the capacity to deal with those.
1 reply
Honestly, at this point, flask-restx is so far behind so many projects in capabilities, even if we merged in a few things, it'd be worth users finding new frameworks
Benjamin "Ziirish" SANS
Thanks j5awry for your time and efforts so far!
And I agree with you about the new frameworks that have more traction
Piotr Borowy
I too thank for work with this framework. Do you have some proposal in some framework to use instead of RestX?
Is there any tutorials for RestX with jinja as I am not able to find any documentaion on google for some frontend with RESTX.
Tiago Tavares
Which ones should I use
I agree. Restx is quite limited