github.com/kaisawind/go-swagger@v0.19.0/fixtures/goparsing/classification/operations_body/todo_operation_body.go (about)

     1  // Copyright 2015 go-swagger maintainers
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package operations
    16  
    17  // ListPetParams the params for the list pets query
    18  type ListPetParams struct {
    19  	// OutOfStock when set to true only the pets that are out of stock will be returned
    20  	OutOfStock bool
    21  }
    22  
    23  // ServeAPI serves the API for this record store
    24  func ServeAPI(host, basePath string, schemes []string) error {
    25  
    26  	// swagger:route GET /pets pets users listPets
    27  	//
    28  	// Lists pets filtered by some parameters.
    29  	//
    30  	// This will show all available pets by default.
    31  	// You can get the pets that are out of stock
    32  	//
    33  	// Consumes:
    34  	// application/json
    35  	// application/x-protobuf
    36  	//
    37  	// Produces:
    38  	// application/json
    39  	// application/x-protobuf
    40  	//
    41  	// Schemes: http, https, ws, wss
    42  	//
    43  	// Security:
    44  	// api_key:
    45  	// oauth: read, write
    46  	//
    47  	// Responses:
    48  	// default: body:genericError
    49  	// 200: body:someResponse
    50  	// 422: body:validationError
    51  	mountItem("GET", basePath+"/pets", nil)
    52  
    53  	/* swagger:route POST /pets pets users createPet
    54  
    55  	Create a pet based on the parameters.
    56  
    57  	Consumes:
    58  	- application/json
    59  	- application/x-protobuf
    60  
    61  	Produces:
    62  	- application/json
    63  	- application/x-protobuf
    64  
    65  	Schemes: http, https, ws, wss
    66  
    67  	Parameters:
    68  	+ name:        request
    69  	  description: The request model.
    70  	  in:          body
    71  	  type:        petModel
    72  	  unknown:     invalid key that will not get parsed. Added to increase coverage.
    73  	+ name:        id
    74  	  description: The pet id
    75  	  in:          path
    76  	  required:    true
    77  	  allowEmpty:  false
    78  
    79  	Responses:
    80  	default: body:genericError
    81  	200: body:someResponse
    82  	422: body:validationError
    83  
    84  	Security:
    85  	api_key:
    86  	oauth: read, write */
    87  	mountItem("POST", basePath+"/pets", nil)
    88  
    89  	// swagger:route GET /orders orders listOrders
    90  	//
    91  	// lists orders filtered by some parameters.
    92  	//
    93  	// Consumes:
    94  	// application/json
    95  	// application/x-protobuf
    96  	//
    97  	// Produces:
    98  	// application/json
    99  	// application/x-protobuf
   100  	//
   101  	// Schemes: http, https, ws, wss
   102  	//
   103  	// Security:
   104  	// api_key:
   105  	// oauth: orders:read, https://www.googleapis.com/auth/userinfo.email
   106  	//
   107  	// Parameters:
   108  	//
   109  	// Responses:
   110  	// default: body:genericError
   111  	// 200: body:someResponse
   112  	// 422: body:validationError
   113  	mountItem("GET", basePath+"/orders", nil)
   114  
   115  	// swagger:route POST /orders orders createOrder
   116  	//
   117  	// create an order based on the parameters.
   118  	//
   119  	// Consumes:
   120  	// application/json
   121  	// application/x-protobuf
   122  	//
   123  	// Produces:
   124  	// application/json
   125  	// application/x-protobuf
   126  	//
   127  	// Schemes: http, https, ws, wss
   128  	//
   129  	// Security:
   130  	// api_key:
   131  	// oauth: read, write
   132  	//
   133  	// Parameters:
   134  	// + name:        id
   135  	//   description: The order id
   136  	//   in:          invalidIn
   137  	//   required:    false
   138  	//   allowEmpty:  true
   139  	//   noValue  (to increase coverage, line without colon, split result will be 1)
   140  	// + name:        request
   141  	//   description: The request model.
   142  	//   in:          body
   143  	//   type:        orderModel
   144  	//
   145  	// Responses:
   146  	// default: body:genericError
   147  	// 200: body:someResponse
   148  	// 422: body:validationError
   149  	mountItem("POST", basePath+"/orders", nil)
   150  
   151  	// swagger:route GET /orders/{id} orders orderDetails
   152  	//
   153  	// gets the details for an order.
   154  	//
   155  	// Consumes:
   156  	// application/json
   157  	// application/x-protobuf
   158  	//
   159  	// Produces:
   160  	// application/json
   161  	// application/x-protobuf
   162  	//
   163  	// Schemes: http, https, ws, wss
   164  	//
   165  	// Security:
   166  	// api_key:
   167  	// oauth: read, write
   168  	//
   169  	// Responses:
   170  	// default: body:genericError
   171  	// 200: body:someResponse
   172  	// 422: body:validationError
   173  	mountItem("GET", basePath+"/orders/:id", nil)
   174  
   175  	// swagger:route PUT /orders/{id} orders updateOrder
   176  	//
   177  	// Update the details for an order.
   178  	//
   179  	// When the order doesn't exist this will return an error.
   180  	//
   181  	// Consumes:
   182  	// application/json
   183  	// application/x-protobuf
   184  	//
   185  	// Produces:
   186  	// application/json
   187  	// application/x-protobuf
   188  	//
   189  	// Schemes: http, https, ws, wss
   190  	//
   191  	// Security:
   192  	// api_key:
   193  	// oauth: read, write
   194  	//
   195  	// Responses:
   196  	// default: body:genericError
   197  	// 200: body:someResponse
   198  	// 422: body:validationError
   199  	mountItem("PUT", basePath+"/orders/:id", nil)
   200  
   201  	// swagger:route DELETE /orders/{id} deleteOrder
   202  	//
   203  	// delete a particular order.
   204  	//
   205  	// Consumes:
   206  	// application/json
   207  	// application/x-protobuf
   208  	//
   209  	// Produces:
   210  	// application/json
   211  	// application/x-protobuf
   212  	//
   213  	// Schemes: http, https, ws, wss
   214  	//
   215  	// Security:
   216  	// api_key:
   217  	// oauth: read, write
   218  	//
   219  	// Responses:
   220  	// default: body:genericError
   221  	// 200: body:someResponse
   222  	// 422: body:validationError
   223  	mountItem("DELETE", basePath+"/orders/:id", nil)
   224  
   225  	// swagger:route POST /param-test params testParams
   226  	//
   227  	// Allow some params with constraints.
   228  	//
   229  	// Consumes:
   230  	// application/json
   231  	// application/x-protobuf
   232  	//
   233  	// Produces:
   234  	// application/json
   235  	// application/x-protobuf
   236  	//
   237  	// Schemes: http, https, ws, wss
   238  	//
   239  	// Security:
   240  	// api_key:
   241  	// oauth: read, write
   242  	//
   243  	// Parameters:
   244  	// + name:        someNumber
   245  	//   description: some number
   246  	//   in:          path
   247  	//   required:    true
   248  	//   allowEmpty:  true
   249  	//   type:        number
   250  	//   max:         20
   251  	//   min:         10
   252  	//   default:     15
   253  	// + name:        someQuery
   254  	//   description: some query values
   255  	//   in:          query
   256  	//   type:        array
   257  	//   minLength:   5
   258  	//   maxLength:   20
   259  	// + name:        someBoolean
   260  	//   in:          path
   261  	//   description: some boolean
   262  	//   type:        boolean
   263  	//   default:     true
   264  	// + name:        constraintsOnInvalidType
   265  	//   description: test constraints on invalid types
   266  	//   in:          query
   267  	//   type:        bool
   268  	//   min:         1
   269  	//   max:         10
   270  	//   minLength:   1
   271  	//   maxLength:   10
   272  	//   format:      abcde
   273  	//   default:     false
   274  	// + name:        noType
   275  	//   description: test no type
   276  	//   min:         1
   277  	//   max:         10
   278  	//   minLength:   1
   279  	//   maxLength:   10
   280  	//   default:     something
   281  	// + name:        request
   282  	//   description: The request model.
   283  	//   in:          body
   284  	//   type:        string
   285  	//   enum:        apple, orange, pineapple, peach, plum
   286  	//   default:     orange
   287  	//
   288  	// Responses:
   289  	// default: body:genericError
   290  	// 200: body:someResponse
   291  	// 422: body:validationError
   292  	mountItem("POST", basePath+"/param-test", nil)
   293  
   294  	return nil
   295  }
   296  
   297  // not really used but I need a method to decorate the calls to
   298  func mountItem(method, path string, handler interface{}) {}