by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Ben Steadman
@SteadBytes
I've got to sign off for tonight now, hopefully we'll have some answers to the questions I mentioned on python-restx/flask-restx#2 and I can get the great renaming of 2020 complete tomorrow :wink:
John Chittum
@j5awry
Awesome! Thanks for all the setup work folks!
John Chittum
@j5awry
for consistency, dead or not, i've put in a PR to restplus remove akamai (since i don't work there and made no code changes). It also specifies what Akamai folks should do in the future
Ben Steadman
@SteadBytes
Awesome, thanks @j5awry
Ibrahima Gaye
@ibstelix
Amazing job, thank you all.
martireg
@martireg
Hello guys, is flask-restx ready for production usage?
Benjamin "Ziirish" SANS
@ziirish
hello @martireg
not yet
martireg
@martireg
Thank you, there is some aprox date┬┐?
Benjamin "Ziirish" SANS
@ziirish
I'll soon release some "usable" packages, but the intent is just to test our CI/automation
soon == by the end of the week
after that, we will work on a proper release as discussed here: noirbizarre/flask-restplus#743
martireg
@martireg
nice
Bhathiya Perera
@JaDogg
That is good to know. Thanks for all your hard work.
lewcianci
@lewcianci
hey everyone, this is probably a dumb question, but i've read the docs and i can't work out how to add an api operation that takes body parameters and produecs a response
i'm also using swagger and swagger ui
so the intent would be to make an operation that takes body parameters of a certain model, does something with those values, and then returns a serialised response to the client
Adam Hughes
@adam.hughes_gitlab
Does anyone know if it's possible to pass a parameter to the constructor of a Resource? I need my Resource to access a GCP client for example
Matt Flaherty
@flayman
Hi all. You're probably not going to get much of a response here to questions. This project has been superseded by flask-restx. Chat is here: https://gitter.im/python-restx
Adam Hughes
@adam.hughes_gitlab
thanks
so we should not use flask-restplus anymore?
or is it jsut the chat that's moved?
Matt Flaherty
@flayman
Flask-restplus will not have any further releases. It is no longer supported. Flask-restx was forked off it a few weeks ago.
Adam Hughes
@adam.hughes_gitlab
ty
Adam Hughes
@adam.hughes_gitlab
sorry - and unreleated question - everytime I make a request to the endpoint associated with my Resource, the resource gets recreated (eg. init()) is called on each request. Is this expected?
oops wrong chat sry
Ankur Shah
@ankurpshah
getting mixcontent error for swagger.json. It is using http instead of https. Tried app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1), still no luck
Franck Kambiwa
@thynquest
hello there
I just learned that flask-restplus is no longer maintained ?
Callam
@cal97g
@thynquest check python-restx/flask-restx
it's a drop in replacement
Harsh Thakur
@harshthakur9030
Hey guys, I want to write a serverless function but write it using flask-restplus. Can someone help me figure out how to do it? I've tried Zappa but that didn't yield the results I was hoping for :/
@SteadBytes @ziirish any idea
Callam
@cal97g
@harshthakur9030 this project is unmaintained.
Sergey Vilgelm
@SVilgelm
@harshthakur9030 How do you see this? The flask-restplus|restx is a Flask's extension that adds support for quickly building REST APIs and Flask is a WSGI web application framework. The both libraries are used to build a web server. I'm not sure how can you use them to implement a server less function.
John Chittum
@j5awry

@harshthakur9030 1) use python-restx not restplus. 2) never done serverless, as I've always done much larger things. Reading this guide made sense: https://medium.com/@Twistacz/flask-serverless-api-in-aws-lambda-the-easy-way-a445a8805028

however I'd have serious doubts about the self-documenting OpenAPI part working properly on serverless. I haven't run across anyone doing it yet

Anthony Torres
@am17torres
Hi all. I'm having some issues configuring flask-restplus to expect a polymorphic input payload on a post route. Does anyone have reference material on how to get this to work?
The two problems I'm facing:
  • api.inherit() doesn't include the model in the schema spec unless I add the model to an ns.expect
  • ns.expect(child1, child2, validate=True) is trying to validate the input payload against both children instead of either or.
ns=api.namespace('todo')
parent = api.model('Parent', {
    'name': fields.String,
    'type': fields.String(discriminator=True)
})

child1 = api.inherit('Child1', parent, {
    'extra': fields.String(required=True)
})

child2 = api.inherit('Child2', parent, {
    'extra2': fields.String(required=True)
})

@ns.route('/')
class TodoList(Resource):
    @ns.doc('create_todo')
    @ns.expect(child1, child2, validate=True)
    def post(self):
        return api.payload
Harsh Thakur
@harshthakur9030
@j5awry I have noticed the OpenAPI thing too and I'm pretty new to serverless. Why don't people document their API in serverless? How would another developer know the functionality the orignal developer created?
John Chittum
@j5awry

@harshthakur9030 I think some of it is not clearly defining serverless, and part of it is from a saving perspective. If you're doing serverless via something like AWS Lambda, they're meant to be fast running functions that spin up and down. long running tasks will end up costing far more than a traditional AWS VM. Having the continuous running service (the openAPI documentation on a continuous webserver) is probably far more expensive.

I haven't really looked at Amazon APIGateway, or other similar services, to see if there is some sort of API documentation service in them. When I hear serverless, I generally think of either Lambdas, which should be small and fast, or something that's more Backend as a Service oriented, with most logic in the client.

https://www.martinfowler.com/articles/serverless.html

Justvuur
@Justvuur
Hi guys, Hope everyone is well and safe! Thanks for this awesome tool! I really enjoy using it. Quick question, is there a way to return a 200 status code with a status message and the json response body? I know there is a way for errors/aborts etc. Just wondering... Got an issue where the POST was performed but I need a warning message to be displayed.
Matt Flaherty
@flayman
Hi @Justvuur. I may be misunderstanding, but returning a custom message with a status code is simple. There is a parameter for description in the @api.response() and and optional one in @api.marshal_with() decorators. See the following example from the documentation:
@api.route('/my-resource/')
class MyResource(Resource):
    @api.response(400, 'Validation error')
    @api.marshal_with(model, code=201, description='Object created')
    def post(self):
        pass
Hello all. A few of you know me. I've contributed a little bit of code to flask-restplus in the past. I would like to contribute more to this project now and I have time on my hands since I've been furloughed from my job. Please let me know of anything in particular that needs doing or I'm happy to join a major rewrite effort. Thanks.
David Cannings
@dc_pwc_gitlab
This message was deleted
Guto Maia
@gutomaia

Hi @Justvuur, i'm facing some error on trying to create a Polymorph List in the response of a service (ex: fields.List(fields.Polymorph(mapping))).

parent_fields = {
    'index': fields.Integer(description='index')
}

parent = ns.model('Parent', parent_fields)

child1_fields = {
    'attr': fields.String(required=True, description='attr'),
}

child1 = parent.inherit('Child1', child1_fields)

child2_fields = {
    'attr': fields.String(required=True, description='attr'),
}

child2 = parent.inherit('Child2', child2_fields)


mapping = {
    child1: child1_fields,
    child2: child2_fields,
}


fields.List(fields.Polymorph(mapping))

That gives a TypeError " TypeError: unhashable type: 'Model'".

Guto Maia
@gutomaia
hi @noirbizarre
Nitendra Singh Yadav
@nitendra-yadav
hi @all, is there any good library in python for users and subscription management?
Justvuur
@Justvuur
@flayman Thanks but would it be possible to change the messing in the method/function depending on the case/outcome?
Matt Flaherty
@flayman
@Justvuur, it's trivial if you want to use a different status code for each outcome. You register each response. If you want to use the same code and different messages, then it doesn't make sense to document them
Nitendra Singh Yadav
@nitendra-yadav
{{{
class ObjectIdVal(fields.Raw):
schema_type = 'string'
schema_example = '54f0e5aa313f5d824680d'
def format(self, id):
try:
x = bson.objectid.ObjectId.is_valid(id)
print(x)
return x
except ValueError as ve:
raise MarshallingError(ve)
def validate(self, id):
"""
Validate the value. return True if valid
"""
print(id)
return False
}}}
hey @noirbizarre , I am unable to get any value in print when adding a field in my model, also its not validating a input string as per the code in format method