-
-
Notifications
You must be signed in to change notification settings - Fork 486
Closed
Description
For the following openapi 3 multi-part:
openapi: 3.0.3
paths:
/endpoint:
post:
operationId: create
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/Request"
components:
schemas:
Request:
type: object
properties:
mystring:
type: string
myint:
type: integer
myobjj:
type: object
And using the following curl command:
curl -X 'POST' 'http://localhost/endpoint' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'mystring=test' \
-F 'myint=0'
-F 'myobj={"key1":"val1"}'
The validation for the myint and myobj fails with
request body has an error: doesn't match schema #/components/schemas/Request: Error at "/myint": value must be an integer
request body has an error: doesn't match schema #/components/schemas/Request: Error at "/myobj": value must be an object
The failures comes from comparing these types with string because all the values are decoded as strings:
interface {}(map[string]interface {}) ["mystring": "...", "myint": "...", "myobj": "..." ]
Is this a valid bug or am I doing something wrong? The only thing I could find was these tickets: #793 and oapi-codegen/oapi-codegen#1169 which are closed without a fix or a workaround.
I am using github.com/deepmap/oapi-codegen/v2 v2.1.0 and github.com/getkin/kin-openapi v0.122.0
miltkall-asml, asml-robin-vanderstraeten, 2minchul, VashUber, Abdullah-AlAttar and 7 more
Metadata
Metadata
Assignees
Labels
No labels