Skip to content

Instantly share code, notes, and snippets.

@ninedraft
Created July 20, 2020 18:51
Show Gist options
  • Save ninedraft/4d9555b1a1f46178cf4fe67510d7b916 to your computer and use it in GitHub Desktop.
Save ninedraft/4d9555b1a1f46178cf4fe67510d7b916 to your computer and use it in GitHub Desktop.
Swagger spec simplified golang model
package swag
type Swag struct {
Openapi string `yaml:"openapi"`
Info Info `yaml:"info"`
Servers []Servers `yaml:"servers"`
Paths map[string]Path `yaml:"paths"`
}
type Info struct {
Title string `yaml:"title"`
Description string `yaml:"description,omitempty"`
Version string `yaml:"version"`
}
type Servers struct {
URL string `yaml:"url"`
Description string `yaml:"description,omitempty"`
}
type Content struct {
Schema *Schema `yaml:"schema,omitempty"`
}
type Response struct {
Description string `yaml:"description,omitempty"`
Content map[string]Content `yaml:"content"`
}
type RequestBody struct {
Required bool `yaml:"required"`
Content map[string]Content `yaml:"content"`
}
type Path struct {
Endpoints map[string]Endpoint `yaml:"endpoints,inline"`
}
type Endpoint struct {
Summary string `yaml:"summary"`
Description string `yaml:"description,omitempty"`
Parameters []Parameter `yaml:"parameters"`
RequestBody *RequestBody `yaml:"requestBody,omitempty"`
Responses map[string]Response `yaml:"responses"`
}
type Parameter struct {
Name string `yaml:"name"`
In string `yaml:"name"`
Required bool `yaml:"required"`
Description string `yaml:"description,omitempty"`
Schema *Schema `yaml:"schema,omitempty"`
}
type Schema struct {
Type string `yaml:"type"`
Items []Schema `yaml:"items,omitempty"`
Properties map[string]Schema `yaml:"properties,omitempty"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment