-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typecasting? #104
Comments
Depends on what you mean, type casting "partly" works, see e.g. https://github.com/hjacobs/connexion-example Can you describe your situation / use case where it fails? |
To reproduce:
swagger: '2.0'
host: localhost
paths:
'/foo/{id}':
get:
operationId: api.get
parameters:
- in: path
name: id
type: integer
format: int64
#!/usr/bin/env python2.7
import connexion
def get(id):
return str(type(id))
app = connexion.App(__name__)
app.add_api('swagger.yml')
application = app.app
if __name__ == '__main__':
app.run(port=8080) http http://localhost:8080/foo/1 Actual:
Expected:
|
Sidenote, this also works ( swagger: '2.0'
host: localhost
paths:
'/foo/{id}':
get:
operationId: api.get
parameters:
- in: path
name: id
type: fantasia It would be nice if connexion was a little more defensive, this way typos can lead to hard to track bugs. |
True, that's a missing feature: Flask route converters should be supported http://flask.pocoo.org/docs/0.10/api/#url-route-registrations |
In the mean time, a small note in the README might save new users some time. I myself was baffled when a |
@kleijnweb my personal recommendation (off topic): stay away from MongoDB 😏 (we replaced a 5 node MongoDB cluster with a single node PostgreSQL 🐘) |
In general we need more documentation and tutorials for Connexion... |
It's only a dummy backend for an AngularJS app, so yeah, not worried about that. Far as docs go, a simple example in the README with a note about how the arguments are passed (including type coercion -- or lack thereof) would go long way. |
@kleijnweb you can check my pull request #105 which adds type casting for int and float path parameters using Flask path converters |
changes now released in https://github.com/zalando/connexion/releases/tag/1.0.25 |
@hjacobs What about arrays/dicts? Difficult? |
@kleijnweb Flask supports custom "converts" in the path, so I don't think it's difficult --- I'm not sure what the semantics are for other types in "path" parameters (need to check Swagger spec) |
connexxion seems to pass Swagger integers as unicode strings. At least a note in the docs would be a start.
The text was updated successfully, but these errors were encountered: