-
-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove formDataBody extra required array
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package openapi2conv | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/getkin/kin-openapi/openapi2" | ||
) | ||
|
||
func TestIssue847(t *testing.T) { | ||
doc2file, err := os.Open("testdata/swagger_formdata_required.json") | ||
require.NoError(t, err) | ||
defer doc2file.Close() | ||
|
||
var doc2 openapi2.T | ||
err = json.NewDecoder(doc2file).Decode(&doc2) | ||
require.NoError(t, err) | ||
|
||
doc3, err := ToV3(&doc2) | ||
require.NoError(t, err) | ||
|
||
reqStr, err := json.MarshalIndent(doc3, "", " ") | ||
_ = reqStr | ||
_ = err | ||
|
||
err = doc3.Validate(context.Background()) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "Hello Java Sec API", | ||
"version": "1.10", | ||
"title": "Swagger2 RESTful API" | ||
}, | ||
"host": "localhost:8888", | ||
"basePath": "/", | ||
"paths": { | ||
"/UPLOAD/uploadSafe": { | ||
"post": { | ||
"operationId": "singleFileUploadSafeUsingPOST", | ||
"consumes": [ | ||
"multipart/form-data" | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "file", | ||
"in": "formData", | ||
"description": "file", | ||
"required": true, | ||
"type": "file" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |