Giter Club home page Giter Club logo

Comments (8)

jdjodrey avatar jdjodrey commented on May 26, 2024 2

Here's what I ended up going with:

def multi_params(*params):
    m = Parameters()
    for p in params:
        m.fields = dict(m.fields, **p.fields)
    return m

And then you can simply put that callable in the decorate and pass in any number of parameter objects to it:

@api.parameters(multi_params(IncludeParameters(), OnlyParameters()))

It's somewhat crude and is definitely limited in handling more complex objects, but it serves my purpose for simple parameters with one or two fields (and it keeps Swagger happy too).

For anyone looking to do something similar, please feel free to improve/refine it!

from flask-restplus-server-example.

soundstripe avatar soundstripe commented on May 26, 2024 1

I'm running across the same problem here. I'd like to add that it would be nice to be able to specify different locations for each set of parameters. Something like:

@api.parameters(AuthenticationParameters(), locations['header', ])
@api.parameters(PaginationParameters(), locations['query', ])
@api.parameters(SearchQueryParameters(), locations=['json', ])
def get():
    return {}

If I come up with anything I'll drop it here.

from flask-restplus-server-example.

frol avatar frol commented on May 26, 2024

Currently, there are no plans to support chained parameters (simply due to the lack of time, and because implementing it the right way may take more time than it might be expected). Multiple Inheritance is the way to go now. Still, you can implement many_params helper yourself. It would be great if you share your experience and the implementation, so we can consider to include it into this example/boilerplate.

Thank you for your interest and sharing this idea!

from flask-restplus-server-example.

jdjodrey avatar jdjodrey commented on May 26, 2024

Good to know, thanks @frol. I'm very appreciative of all your hard work on this project, and if I end up going the helper method route, I'll be sure to post my implementation details back here.

from flask-restplus-server-example.

frol avatar frol commented on May 26, 2024

@jdjodrey Thanks for sharing. I will just comment an obvious limitation of your implementation: custom validations defined on the classes will be ignored, and the reason I haven't touched it is that I have no idea on how to merge @validates_schema handlers.

from flask-restplus-server-example.

joeyorlando avatar joeyorlando commented on May 26, 2024

👍 on this

from flask-restplus-server-example.

bitfinity avatar bitfinity commented on May 26, 2024

@jdjodrey Your method has been working quite well for me.

from flask-restplus-server-example.

Hatuw avatar Hatuw commented on May 26, 2024

Thanks for @jdjodrey sharing. But it seems that not support locations='path'. I don't know how to adapt your method...Could you help me? pls @jdjodrey

from flask-restplus-server-example.

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.