1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 12:20:54 +00:00

golint swagger

This commit is contained in:
astaxie 2015-09-12 23:15:23 +08:00
parent 172894efe8
commit a289b08e64

View File

@ -12,53 +12,59 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// swagger struct definition // Package swagger struct definition
package swagger package swagger
// SwaggerVersion show the current swagger version
const SwaggerVersion = "1.2" const SwaggerVersion = "1.2"
// ResourceListing list the resource
type ResourceListing struct { type ResourceListing struct {
ApiVersion string `json:"apiVersion"` APIVersion string `json:"apiVersion"`
SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2 SwaggerVersion string `json:"swaggerVersion"` // e.g 1.2
// BasePath string `json:"basePath"` obsolete in 1.1 // BasePath string `json:"basePath"` obsolete in 1.1
Apis []ApiRef `json:"apis"` APIs []APIRef `json:"apis"`
Infos Infomation `json:"info"` Infos Infomation `json:"info"`
} }
type ApiRef struct { // APIRef description the api path and description
type APIRef struct {
Path string `json:"path"` // relative or absolute, must start with / Path string `json:"path"` // relative or absolute, must start with /
Description string `json:"description"` Description string `json:"description"`
} }
// Infomation show the API Infomation
type Infomation struct { type Infomation struct {
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
Contact string `json:"contact,omitempty"` Contact string `json:"contact,omitempty"`
TermsOfServiceUrl string `json:"termsOfServiceUrl,omitempty"` TermsOfServiceURL string `json:"termsOfServiceUrl,omitempty"`
License string `json:"license,omitempty"` License string `json:"license,omitempty"`
LicenseUrl string `json:"licenseUrl,omitempty"` LicenseURL string `json:"licenseUrl,omitempty"`
} }
// https://github.com/wordnik/swagger-core/blob/scala_2.10-1.3-RC3/schemas/api-declaration-schema.json // APIDeclaration see https://github.com/wordnik/swagger-core/blob/scala_2.10-1.3-RC3/schemas/api-declaration-schema.json
type ApiDeclaration struct { type APIDeclaration struct {
ApiVersion string `json:"apiVersion"` APIVersion string `json:"apiVersion"`
SwaggerVersion string `json:"swaggerVersion"` SwaggerVersion string `json:"swaggerVersion"`
BasePath string `json:"basePath"` BasePath string `json:"basePath"`
ResourcePath string `json:"resourcePath"` // must start with / ResourcePath string `json:"resourcePath"` // must start with /
Consumes []string `json:"consumes,omitempty"` Consumes []string `json:"consumes,omitempty"`
Produces []string `json:"produces,omitempty"` Produces []string `json:"produces,omitempty"`
Apis []Api `json:"apis,omitempty"` APIs []API `json:"apis,omitempty"`
Models map[string]Model `json:"models,omitempty"` Models map[string]Model `json:"models,omitempty"`
} }
type Api struct { // API show tha API struct
type API struct {
Path string `json:"path"` // relative or absolute, must start with / Path string `json:"path"` // relative or absolute, must start with /
Description string `json:"description"` Description string `json:"description"`
Operations []Operation `json:"operations,omitempty"` Operations []Operation `json:"operations,omitempty"`
} }
// Operation desc the Operation
type Operation struct { type Operation struct {
HttpMethod string `json:"httpMethod"` HTTPMethod string `json:"httpMethod"`
Nickname string `json:"nickname"` Nickname string `json:"nickname"`
Type string `json:"type"` // in 1.1 = DataType Type string `json:"type"` // in 1.1 = DataType
// ResponseClass string `json:"responseClass"` obsolete in 1.2 // ResponseClass string `json:"responseClass"` obsolete in 1.2
@ -72,15 +78,18 @@ type Operation struct {
Protocols []Protocol `json:"protocols,omitempty"` Protocols []Protocol `json:"protocols,omitempty"`
} }
// Protocol support which Protocol
type Protocol struct { type Protocol struct {
} }
// ResponseMessage Show the
type ResponseMessage struct { type ResponseMessage struct {
Code int `json:"code"` Code int `json:"code"`
Message string `json:"message"` Message string `json:"message"`
ResponseModel string `json:"responseModel"` ResponseModel string `json:"responseModel"`
} }
// Parameter desc the request parameters
type Parameter struct { type Parameter struct {
ParamType string `json:"paramType"` // path,query,body,header,form ParamType string `json:"paramType"` // path,query,body,header,form
Name string `json:"name"` Name string `json:"name"`
@ -94,17 +103,20 @@ type Parameter struct {
Maximum int `json:"maximum"` Maximum int `json:"maximum"`
} }
// ErrorResponse desc response
type ErrorResponse struct { type ErrorResponse struct {
Code int `json:"code"` Code int `json:"code"`
Reason string `json:"reason"` Reason string `json:"reason"`
} }
// Model define the data model
type Model struct { type Model struct {
Id string `json:"id"` ID string `json:"id"`
Required []string `json:"required,omitempty"` Required []string `json:"required,omitempty"`
Properties map[string]ModelProperty `json:"properties"` Properties map[string]ModelProperty `json:"properties"`
} }
// ModelProperty define the properties
type ModelProperty struct { type ModelProperty struct {
Type string `json:"type"` Type string `json:"type"`
Description string `json:"description"` Description string `json:"description"`
@ -112,20 +124,20 @@ type ModelProperty struct {
Format string `json:"format"` Format string `json:"format"`
} }
// https://github.com/wordnik/swagger-core/wiki/authorizations // Authorization see https://github.com/wordnik/swagger-core/wiki/authorizations
type Authorization struct { type Authorization struct {
LocalOAuth OAuth `json:"local-oauth"` LocalOAuth OAuth `json:"local-oauth"`
ApiKey ApiKey `json:"apiKey"` APIKey APIKey `json:"apiKey"`
} }
// https://github.com/wordnik/swagger-core/wiki/authorizations // OAuth see https://github.com/wordnik/swagger-core/wiki/authorizations
type OAuth struct { type OAuth struct {
Type string `json:"type"` // e.g. oauth2 Type string `json:"type"` // e.g. oauth2
Scopes []string `json:"scopes"` // e.g. PUBLIC Scopes []string `json:"scopes"` // e.g. PUBLIC
GrantTypes map[string]GrantType `json:"grantTypes"` GrantTypes map[string]GrantType `json:"grantTypes"`
} }
// https://github.com/wordnik/swagger-core/wiki/authorizations // GrantType see https://github.com/wordnik/swagger-core/wiki/authorizations
type GrantType struct { type GrantType struct {
LoginEndpoint Endpoint `json:"loginEndpoint"` LoginEndpoint Endpoint `json:"loginEndpoint"`
TokenName string `json:"tokenName"` // e.g. access_code TokenName string `json:"tokenName"` // e.g. access_code
@ -133,16 +145,16 @@ type GrantType struct {
TokenEndpoint Endpoint `json:"tokenEndpoint"` TokenEndpoint Endpoint `json:"tokenEndpoint"`
} }
// https://github.com/wordnik/swagger-core/wiki/authorizations // Endpoint see https://github.com/wordnik/swagger-core/wiki/authorizations
type Endpoint struct { type Endpoint struct {
Url string `json:"url"` URL string `json:"url"`
ClientIdName string `json:"clientIdName"` ClientIDName string `json:"clientIdName"`
ClientSecretName string `json:"clientSecretName"` ClientSecretName string `json:"clientSecretName"`
TokenName string `json:"tokenName"` TokenName string `json:"tokenName"`
} }
// https://github.com/wordnik/swagger-core/wiki/authorizations // APIKey see https://github.com/wordnik/swagger-core/wiki/authorizations
type ApiKey struct { type APIKey struct {
Type string `json:"type"` // e.g. apiKey Type string `json:"type"` // e.g. apiKey
PassAs string `json:"passAs"` // e.g. header PassAs string `json:"passAs"` // e.g. header
} }