Skip to content

Commit

Permalink
fill some base openapi info for test
Browse files Browse the repository at this point in the history
  • Loading branch information
futugyou authored Jul 25, 2024
1 parent 991ba6a commit bb44d47
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tour/internal/openapi/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/go-openapi/spec"
"github.com/swaggest/openapi-go/openapi31"
"gopkg.in/yaml.v3"

util "github.com/futugyou/extensions"
)

func ConvertSwaggerToOpenapi(path string, outpath string) error {
Expand Down Expand Up @@ -41,13 +43,19 @@ func convertSwaggerToOpenAPI(swagger *spec.Swagger) *openapi31.Spec {
openAPI := &openapi31.Spec{
Openapi: "3.0.0",
Info: openapi31.Info{
Title: swagger.Info.Title,
Description: &swagger.Info.Description,
Version: swagger.Info.Version,
},
Paths: &openapi31.Paths{
MapOfPathItemValues: map[string]openapi31.PathItem{},
MapOfAnything: map[string]interface{}{},
Title: swagger.Info.Title,
Description: &swagger.Info.Description,
TermsOfService: &swagger.Info.TermsOfService,
Contact: &openapi31.Contact{
Name: util.GetStringFieldPointer(swagger, "Info", "Contact", "Name"),
URL: util.GetStringFieldPointer(swagger, "Info", "Contact", "URL"),
Email: util.GetStringFieldPointer(swagger, "Info", "Contact", "Email"),
},
License: &openapi31.License{
Name: util.GetStringFieldStruct(swagger, "Info", "License", "Name"),
URL: util.GetStringFieldPointer(swagger, "Info", "License", "URL"),
},
Version: swagger.Info.Version,
},
}

Expand Down

0 comments on commit bb44d47

Please sign in to comment.