Started creating introduction screen

This commit is contained in:
frikky
2020-08-26 20:02:46 +02:00
parent f61f59981c
commit 0fc9c78385
8 changed files with 380 additions and 21 deletions
+34
View File
@@ -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)