mirror of
https://github.com/davidebianchi/gswagger.git
synced 2025-12-23 23:38:43 -05:00
Added test using enum in request body schema (#157)
This commit is contained in:
@@ -48,6 +48,7 @@ func TestAddRoutes(t *testing.T) {
|
||||
FirstName string `json:"firstName" jsonschema:"title=user first name"`
|
||||
LastName string `json:"lastName" jsonschema:"title=user last name"`
|
||||
Metadata interface{} `json:"metadata,omitempty" jsonschema:"title=custom properties,oneof_type=string;number"`
|
||||
UserType string `json:"userType,omitempty" jsonschema:"title=type of user,enum=simple,enum=advanced"`
|
||||
}
|
||||
|
||||
okHandler := func(w http.ResponseWriter, req *http.Request) {
|
||||
@@ -376,7 +377,7 @@ func TestAddRoutes(t *testing.T) {
|
||||
fixturesPath: "testdata/anyof.json",
|
||||
},
|
||||
{
|
||||
name: "oneOf support on properties",
|
||||
name: "oneOf and enum are supported on properties",
|
||||
routes: func(t *testing.T, router *TestRouter) {
|
||||
_, err := router.AddRoute(http.MethodPost, "/user-profile", okHandler, Definitions{
|
||||
RequestBody: &ContentValue{
|
||||
|
||||
5
testdata/oneOf.json
vendored
5
testdata/oneOf.json
vendored
@@ -78,6 +78,11 @@
|
||||
}
|
||||
],
|
||||
"title": "custom properties"
|
||||
},
|
||||
"userType": {
|
||||
"title": "type of user",
|
||||
"type": "string",
|
||||
"enum": ["simple", "advanced"]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
Reference in New Issue
Block a user