Questions tagged [connexion]

Connexion is a framework that automagically handles HTTP requests based on OpenAPI Specification (formerly known as Swagger Spec) of your API described in YAML format.

151 questions
24
votes
2 answers

How to test a Connexion/Flask app?

I'm using the Connexion framework for Flask to build a microservice. I would like to write tests for my application using py.test. In the pytest-flask doc it says to create a fixture in conftest.py that creates the app like so: conftest.py import…
Sebastian Wozny
  • 16,943
  • 7
  • 52
  • 69
10
votes
1 answer

Integrating Swagger/OpenAPI generated python server with existing Flask application

I am interested in integrating a swagger-codegen generated Python server with an existing Flask application. swagger-codegen generates a Python implementation based on the Connexion library from a Swagger API specification. The examples I have…
user650881
  • 2,214
  • 19
  • 31
8
votes
1 answer

any workaround to add token authorization decorator to endpoint at swagger python server stub

I know how to secure endpoint in flask, and I want to do the same thing to swagger generated python server stub. I am wondering how I can integrate flask token authentication works for the swagger python server, so the endpoint will be secured. I…
kim
  • 556
  • 7
  • 28
8
votes
1 answer

Pytest: Inherit fixture from parent class

I have a couple of test cases to test the endpoints of a flask/connexion based api. Now I want to reorder them into classes, so there is a base class: import pytest from unittest import TestCase # Get the connexion app with the database…
Tamwyn
  • 312
  • 4
  • 16
8
votes
1 answer

How to pass a variable into Connexion Flask app context?

I run Connexion/Flask app like this: import connexion from flask_cors import CORS from flask import g app = connexion.App(__name__, specification_dir='swagger_server/swagger/') app.add_api('swagger.yaml') CORS(app.app) with app.app.app_context(): …
Michal Špondr
  • 1,337
  • 2
  • 21
  • 44
8
votes
1 answer

Connexion class based handling

I'm using the connexion framework for flask. I'd like to group several related functions into a class and I'm wondering whether methods of a class can be used for operationId instead of functions. Something like class Job: def get(): …
Akhil Batra
  • 581
  • 4
  • 16
7
votes
1 answer

OpenAPI 3 - readOnly property, but allow write in POST/PUT

Is there a way to represent a property as generally readOnly, but allow the property to be written during a POST or PUT (i.e. a create or replace) action? In other words, when creating the resource, I'd like the property to be writable. But once the…
crunk1
  • 2,560
  • 1
  • 26
  • 32
5
votes
3 answers

ImportError: cannot import name 'FileStorage' from 'werkzeug'

We are getting: File "/usr/lib/python2.7/site-packages/connexion/decorators/validation.py", line 9, in from werkzeug import FileStorage since we are working with Python 2.7.x upgrading connexion==2.6.0 is not an option.
Amit Talmor
  • 7,174
  • 4
  • 25
  • 29
5
votes
0 answers

Best approach to use swagger generated data-models in business logic app

I have a Python program which encapsulates the business logic of an app. An example: $ app pets list [{ "name": "Hasso", "age": 21 },{ "name": "Lassy", "age": 15 }] Now I want to realize a REST API with Swagger.io. An extract of the YAML…
Maus
  • 2,724
  • 5
  • 32
  • 37
4
votes
0 answers

Swagger OpenAPI3 POST Array of images and media file together

I am using the swagger python-flask framework to create an OpenAPI 3 API which needs to do the following: 1. Upload a video file 2. Upload an array of images 3. Upload extra string data. I can successfully upload a single file successfully…
Harry Boy
  • 4,159
  • 17
  • 71
  • 122
4
votes
1 answer

Access Flask methods like before_request when using Connexion

I'm building an API using Connexion, so I'm using app = connexion.FlaskApp(__name__) instead of instead of Flask(__name__). I want to add before_request and after_request handlers to open and close a database connection. However, since app is a…
Denton Zhou
  • 75
  • 1
  • 8
4
votes
2 answers

Swagger adding custom attributes to parameter definition

We have a python web server app based on connexion and Flask libraries. For audit purposes we print every request, including request body, to the logs. Those logs are much more extensive than what Flask prints by default. However, there are…
vmax33
  • 643
  • 5
  • 13
4
votes
2 answers

In a connexion/flask app, how can I fake post requests with parameters in body for endpoint?

I'm trying to test my connexion app, I've followed the link here, And the get requests seem to be working fine. Now I'm trying to test post requests, but the endpoint method takes in parameters as arguments. My set up is very similar to the one…
Humair
  • 91
  • 5
3
votes
1 answer

Swagger codegen, custom code and new stub

I am tinkering with Swagger Codegen for Python and the Petstore example. I see that the generated stubs rely on Python libraries (swagger_sever, connexion,...). import connexion import six from swagger_server.models.api_response import ApiResponse …
Luca P.
  • 1,021
  • 8
  • 20
3
votes
1 answer

Using the models generated by OpenAPI Generator with sqlalchemy

I have generated a python-flask server based upon my OAS API schema (say PETS.yaml) using the OpenAPI Generator. docker run --rm \ -v ${PWD}:/local openapitools/openapi-generator-cli generate \ -i /local/petstore.yaml \ -g go \ -o…
KarateKid
  • 3,138
  • 4
  • 20
  • 39
1
2 3
9 10