Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extensions in missing resources #306

Merged
merged 2 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions openapi2/openapi2.go
Expand Up @@ -237,11 +237,20 @@ func (response *Response) UnmarshalJSON(data []byte) error {
}

type Header struct {
openapi3.ExtensionProps
Ref string `json:"$ref,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
}

func (header *Header) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(header)
}

func (header *Header) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, header)
}

type SecurityRequirements []map[string][]string

type SecurityScheme struct {
Expand Down
17 changes: 13 additions & 4 deletions openapi3/server.go
Expand Up @@ -45,12 +45,12 @@ type Server struct {
Variables map[string]*ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"`
}

func (value *Server) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(value)
func (server *Server) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(server)
}

func (value *Server) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, value)
func (server *Server) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, server)
}

func (server Server) ParameterNames() ([]string, error) {
Expand Down Expand Up @@ -138,11 +138,20 @@ func (server *Server) Validate(c context.Context) (err error) {

// ServerVariable is specified by OpenAPI/Swagger standard version 3.0.
type ServerVariable struct {
ExtensionProps
Enum []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

func (serverVariable *ServerVariable) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(serverVariable)
}

func (serverVariable *ServerVariable) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, serverVariable)
}

func (serverVariable *ServerVariable) Validate(c context.Context) error {
switch serverVariable.Default.(type) {
case float64, string:
Expand Down
11 changes: 11 additions & 0 deletions openapi3/tag.go
@@ -1,5 +1,7 @@
package openapi3

import "github.com/getkin/kin-openapi/jsoninfo"

// Tags is specified by OpenAPI/Swagger 3.0 standard.
type Tags []*Tag

Expand All @@ -14,7 +16,16 @@ func (tags Tags) Get(name string) *Tag {

// Tag is specified by OpenAPI/Swagger 3.0 standard.
type Tag struct {
ExtensionProps
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
}

func (t *Tag) MarshalJSON() ([]byte, error) {
return jsoninfo.MarshalStrictStruct(t)
}

func (t *Tag) UnmarshalJSON(data []byte) error {
return jsoninfo.UnmarshalStrictStruct(data, t)
}