50 lines
1.6 KiB
Go Template
50 lines
1.6 KiB
Go Template
// Code generated by go-swagger; DO NOT EDIT.
|
|
|
|
|
|
{{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }}
|
|
|
|
|
|
package types
|
|
{{ $package := "types" }}
|
|
|
|
// This file was generated by the swagger tool.
|
|
// Editing this file might prove futile when you re-run the swagger generate command
|
|
|
|
// NewSwaggerSpec creates a new SwaggerSpec instance
|
|
func NewSwaggerSpec() *SwaggerSpec {
|
|
|
|
spec := &SwaggerSpec{
|
|
Handlers: make(map[string]map[string]bool),
|
|
}
|
|
|
|
if len(spec.Handlers) == 0 {
|
|
spec.initHandlerCache()
|
|
}
|
|
|
|
return spec
|
|
}
|
|
|
|
/*SwaggerSpec {{ if .Info }}{{ if .Info.Description }}{{.Info.Description}}{{ else }}the {{ humanize .Name }} API{{ end }}{{ end }} */
|
|
type SwaggerSpec struct {
|
|
Handlers map[string]map[string]bool
|
|
}
|
|
|
|
func ({{.ReceiverName}} *SwaggerSpec) initHandlerCache() {
|
|
{{- if .Operations }}
|
|
{{.ReceiverName}}.Handlers = make(map[string]map[string]bool)
|
|
|
|
// https://swagger.io/specification/v2/ fixed fields: GET, PUT, POST, DELETE, OPTIONS, HEAD, PATCH
|
|
{{.ReceiverName}}.Handlers["GET"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["PUT"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["POST"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["DELETE"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["OPTIONS"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["HEAD"] = make(map[string]bool)
|
|
{{.ReceiverName}}.Handlers["PATCH"] = make(map[string]bool)
|
|
{{ range .Operations }}
|
|
{{.ReceiverName}}.Handlers[{{ printf "%q" (upper .Method) }}][{{ if eq .Path "/" }}""{{ else }}{{ printf "%q" (cleanPath .Path) }}{{ end }}] = true
|
|
{{- end }}
|
|
{{- end }}
|
|
}
|
|
|