Started creating introduction screen
This commit is contained in:
@@ -456,6 +456,40 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
|
||||
}
|
||||
}
|
||||
|
||||
// Jesus what a clusterfuck.
|
||||
// Handles parsing of categories from OpenApi3 custom field
|
||||
if val, ok := swagger.Info.ExtensionProps.Extensions["x-categories"]; ok {
|
||||
log.Printf("Categories: %#v", val)
|
||||
j, err := json.Marshal(&val)
|
||||
if err == nil {
|
||||
if j[0] == 0x22 && j[len(j)-1] == 0x22 {
|
||||
j = j[1 : len(j)-1]
|
||||
}
|
||||
|
||||
parsedCategories := fmt.Sprintf(`{"categories": %s}`, string(j))
|
||||
type parsed struct {
|
||||
Categories []string `json:"categories"`
|
||||
}
|
||||
|
||||
var parse parsed
|
||||
err := json.Unmarshal([]byte(parsedCategories), &parse)
|
||||
if err != nil {
|
||||
log.Printf("Failed unmarshaling categories", err)
|
||||
} else {
|
||||
api.Categories = parse.Categories
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(swagger.Tags) > 0 {
|
||||
newTags := []string{}
|
||||
for _, tag := range swagger.Tags {
|
||||
newTags = append(newTags, tag.Name)
|
||||
}
|
||||
|
||||
api.Tags = newTags
|
||||
}
|
||||
|
||||
securitySchemes := swagger.Components.SecuritySchemes
|
||||
if securitySchemes != nil {
|
||||
//log.Printf("%#v", securitySchemes)
|
||||
|
||||
Reference in New Issue
Block a user