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 using: MyFileUploadAPI: post: operationId: my_file_upload requestBody: content: multipart/form-data: schema: $ref: '#/components/schemas/videofile' components: schemas: videofile: type: object properties: upload: type: string format: binary # This works fine def my_file_upload(videofile): file_name = videofile.filename And I can upload an array of images and other data using: MyMultipleImagesUploadAPI: post: operationId: multiple_files requestBody: content: application/json: schema: $ref: '#/components/schemas/multiplefiles' components: schemas: multiplefiles: type: object properties: Images: items: $ref: '#/components/schemas/MyImage' TotalCount: type: integer # This works fine def multiple_files(body): if connexion.request.is_json: body = multiplefiles.from_dict(connexion.request.get_json()) images = body._images count = body._totalcount Now I wish to combine the two together (Video upload + Multiple images + extra data) So I have did the following: /MyEverythingAPI: post: operationId: video_multiple_images requestBody: content: multipart/form-data: schema: $ref: '#/components/schemas/everything' components: schemas: everything: type: object properties: Video: type: string format: binary Images: type: array items: $ref: '#/components/schemas/MyImage' TotalCount: type: integer # This has issues def video_multiple_images(body, video_clip, **kwargs): #body = {'images': ['[object File]'], 'totalcount': 2} uploaded_file_name = video_clip.filename Now there are 2 issues that I see that are just not correct: Issue 1. The video_clip was not getting passed through to the function video_multiple_images. I debugged and tracked it down and saw that it was not getting added because there were no **kwargs added to my function signature. When I added the**kwargs then the video file started to get passed through. This post helped me solve that part: https://github.com/zalando/connexion/pull/753/files I can live with this issue but would like to know why this is the case. Issue 2. The image array is coming through as [object File]''[Object File]'' etc. This post indicates that this is not supported in OpenAPI 3: In Swagger openapi v3.0.0, facing issue in multiple file uploads So how can I pass a video file + an array of images?1.4KViews0likes0CommentsWhich library to use to implement OpenAPI
hello, I'm going to implement many new web microservices. I'm discovering OpenAPI (YAML/JSON Schema), and and I'm enthusiastic about it. But I'm lost in the existing libraries implementing it. I would like to use Python and I'm familar with flask; but then... what do you think of: connexion: https://github.com/zalando/connexion flasgger: https://github.com/flasgger/flasgger swagger-ui: https://pypi.org/project/swagger-ui-py flask-swagger-ui: https://pypi.org/project/flask-swagger-ui flask-restplus: https://flask-restplus.readthedocs.io/en/stable flask-rest-api: https://flask-rest-api.readthedocs.io/en/stable flask-restful: https://flask-restful.readthedocs.io/en/latest/ can you guide me to use the right promising libraries, with large communities. Many thanks. GuillaumeSwagger Python Flask server sluggish over HTTPS
I have a swagger openapi v3 python flask generated REST API server. I have just added HTTPS support to it and have used a self signed cert as follows. CERTIFICATE_FILE = '/cert/server-cert.pem' KEY_FILE = '/cert/server-key.pem' def main(): app = connexion.App(__name__, specification_dir='./swagger/') app.app.json_encoder = encoder.JSONEncoder app.add_api('swagger.yaml', arguments={'title': 'My API'}, pythonic_params=True) CORS(app.app) app.run(port=8080, debug=True, ssl_context=(CERTIFICATE_FILE, KEY_FILE)) I assess the swagger UI as follows: https://10.190.111.23:8080/ui/ I notice that very often there is a very long rersponse time when the swagger UI loads in the web browser and lots of times it does not load at all and simply times out. If I do not use HTTPS then it loads fine every time. Why could this be?