Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Schnides123 committed Jan 3, 2024
1 parent f370ec6 commit 7197aef
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/integration/pkg/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions test/integration/testdata/golden.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,50 @@
}
}
}
},
"/test/valuevalidation/foo4": {
"get": {
"produces": [
"application/json"
],
"schemes": [
"https"
],
"operationId": "get-valuevalidation.Foo4",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/valuevalidation.Foo4"
}
},
"404": {
"$ref": "#/responses/NotFound"
}
}
}
},
"/test/valuevalidation/foo5": {
"get": {
"produces": [
"application/json"
],
"schemes": [
"https"
],
"operationId": "get-valuevalidation.Foo5",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/valuevalidation.Foo5"
}
},
"404": {
"$ref": "#/responses/NotFound"
}
}
}
}
},
"definitions": {
Expand Down Expand Up @@ -1235,6 +1279,15 @@
"type": "string",
"format": "string",
"maxProperties": 5
},
"valuevalidation.Foo4": {
"type": "integer"
},
"valuevalidation.Foo5": {
"type": "test-type",
"format": "test-format",
"maxProperties": 5,
"minProperties": 1
}
},
"responses": {
Expand Down
46 changes: 46 additions & 0 deletions test/integration/testdata/golden.v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,46 @@
}
}
}
},
"/test/valuevalidation/foo4": {
"get": {
"operationId": "get-valuevalidation.Foo4",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/valuevalidation.Foo4"
}
}
}
},
"404": {
"$ref": "#/components/responses/NotFound"
}
}
}
},
"/test/valuevalidation/foo5": {
"get": {
"operationId": "get-valuevalidation.Foo5",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/valuevalidation.Foo5"
}
}
}
},
"404": {
"$ref": "#/components/responses/NotFound"
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -1205,6 +1245,12 @@
"type": "string"
}
]
},
"valuevalidation.Foo4": {
"type": "integer"
},
"valuevalidation.Foo5": {
"type": "object"
}
},
"responses": {
Expand Down
38 changes: 38 additions & 0 deletions test/integration/testdata/valuevalidation/alpha.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,41 @@ func (Foo3) OpenAPISchemaType() []string {
func (Foo3) OpenAPISchemaFormat() string {
return "string"
}

// this one should ignore marker comments
// +k8s:openapi-gen=true
// +k8s:validation:maximum=6
type Foo4 struct{}

func (Foo4) OpenAPIDefinition() common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"integer"},
},
},
}
}

// +k8s:openapi-gen=true
// +k8s:validation:maxProperties=5
// +k8s:validation:minProperties=1
type Foo5 struct{}

func (Foo5) OpenAPIV3Definition() common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
},
},
}
}

func (Foo5) OpenAPISchemaType() []string {
return []string{"test-type"}
}

func (Foo5) OpenAPISchemaFormat() string {
return "test-format"
}
2 changes: 2 additions & 0 deletions test/integration/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ func CreateWebServices(includeV2SchemaAnnotation bool) []*restful.WebService {
addRoutes(w, buildRouteForType(w, "custom", "Bah")...)
addRoutes(w, buildRouteForType(w, "valuevalidation", "Foo2")...)
addRoutes(w, buildRouteForType(w, "valuevalidation", "Foo3")...)
addRoutes(w, buildRouteForType(w, "valuevalidation", "Foo4")...)
addRoutes(w, buildRouteForType(w, "valuevalidation", "Foo5")...)
}
addRoutes(w, buildRouteForType(w, "maptype", "GranularMap")...)
addRoutes(w, buildRouteForType(w, "maptype", "AtomicMap")...)
Expand Down

0 comments on commit 7197aef

Please sign in to comment.