I'm trying to process a simple HTML form from a Python application described using OpenAPI 2.0 and generating the Flask-Connexion code using OpenAPI Generator v4.3.1 and v5.0.1, but I always get a response like:
"['whatever'] is not of type 'string'"
This is my OpenAPI 2.0 spec, and it seems to fit with the section "Form Parameters" of https://swagger.io/docs/specification/2-0/describing-parameters/ :
swagger: "2.0"
info:
version: "1.0.0"
title: "Test"
host: localhost:8080
basePath: /api
schemes:
- http
paths:
/mytest:
post:
operationId: process_test_form
consumes:
- application/x-www-form-urlencoded
produces:
- text/html; charset=utf-8
parameters:
- name: myparam
in: formData
description: "my param"
type: string
required: True
responses:
"200":
description: "Success"
schema:
type: string
I generate the Python application with OpenAPI Generator 4.3.1 and v5.0.1 like this:
java -jar openapi-generator-cli-4.3.1.jar generate -g python-flask -i ./spec.yml
Respecting the generated "requeriments.txt" I did "pip3 install -r requirements.txt" , so I'm finally using:
Werkzeug (0.16.1)
swagger-ui-bundle (0.0.8)
python-dateutil (2.8.1)
setuptools (39.0.1)
connexion (2.7.0)
Then I run the generated code it like this:
python3 -m openapi_server
It can be easyly tested with a simple HTML form like this:
<html>
<body>
<h1>My test</h1>
<form action="http://0.0.0.0:8080/api/mytest" method="post">
<input type="text" name="myparam"><br/>
<input type="submit" name="Accept"><br/>
</form>
</body>
</html>
But it always get the error:
"['anytextentered'] is not of type 'string'"
I can't find what's wrong. The EndPoint is created and it's correctly targeted from the form, because if I omit the parameters I get an error ""'myparam' is a required property"". Maybe there's something missing in the generated requeriments.txt ?
Any help will be very appreciated. Thanks in advance! /Ángel
Edit: I tested the v3.0 spec given by Software2 and it generates the same error in my environment (I'm using the one generated by "OpenAPI Generator"). A working "requeriments.txt" would be appreciated.