github.com/dirkm/go-swagger@v0.19.0/examples/composed-auth/restapi/embedded_spec.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package restapi
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"encoding/json"
    10  )
    11  
    12  var (
    13  	// SwaggerJSON embedded version of the swagger document used at generation time
    14  	SwaggerJSON json.RawMessage
    15  	// FlatSwaggerJSON embedded flattened version of the swagger document used at generation time
    16  	FlatSwaggerJSON json.RawMessage
    17  )
    18  
    19  func init() {
    20  	SwaggerJSON = json.RawMessage([]byte(`{
    21    "consumes": [
    22      "application/json"
    23    ],
    24    "produces": [
    25      "application/json"
    26    ],
    27    "schemes": [
    28      "http"
    29    ],
    30    "swagger": "2.0",
    31    "info": {
    32      "description": "This sample API demonstrates how to compose several authentication schemes\nand configure complex security requirements for your operations.\n\nThis API simulates a very simple market place with customers and resellers\nof items.\n\nPersonas:\n  - as a first time user, I want to see all items on sales\n  - as a registered customer, I want to post orders for items and\n    consult my past orders\n  - as a registered reseller, I want to see all pending orders on the items\n    I am selling on the market place\n  - as a reseller managing my own inventories, I want to post replenishment orders for the items I provide\n  - as a register user, I want to consult my personal account infos\n\nThe situation we defined on the authentication side is as follows:\n  - every known user is authenticated using a basic token\n  - resellers are authenticated using API keys - we let the option to authenticate using a header or query param\n  - any registered user (customer or reseller) will add a signed JWT to access more API endpoints\n\nObviously, there are several ways to achieve the same result. We just wanted to demonstrate here how\nsecurity requirements may compose several schemes.\n\nNote that we used the \"OAuth2\" declaration here but don't implement a real\nOAuth2 workflow: our intend here is just to be able to extract scopes from a passed JWT token (the\nonly way to manipulate scoped authorizers with Swagger 2.0 is to declare them with type \"oauth2\").\n",
    33      "title": "Composing authorizations",
    34      "version": "0.0.1"
    35    },
    36    "basePath": "/api",
    37    "paths": {
    38      "/account": {
    39        "get": {
    40          "security": [
    41            {
    42              "isRegistered": []
    43            }
    44          ],
    45          "description": "Every registered user should be able to access this operation\n",
    46          "summary": "registered user account",
    47          "operationId": "GetAccount",
    48          "responses": {
    49            "200": {
    50              "description": "registered user personal account infos",
    51              "schema": {
    52                "type": "object",
    53                "additionalProperties": true
    54              }
    55            },
    56            "401": {
    57              "$ref": "#/responses/unauthorized"
    58            },
    59            "default": {
    60              "$ref": "#/responses/otherError"
    61            }
    62          }
    63        }
    64      },
    65      "/items": {
    66        "get": {
    67          "security": [],
    68          "description": "Everybody should be able to access this operation\n",
    69          "summary": "items on sale",
    70          "operationId": "GetItems",
    71          "responses": {
    72            "200": {
    73              "$ref": "#/responses/multipleItems"
    74            },
    75            "default": {
    76              "$ref": "#/responses/otherError"
    77            }
    78          }
    79        }
    80      },
    81      "/order/add": {
    82        "post": {
    83          "security": [
    84            {
    85              "hasRole": [
    86                "customer"
    87              ],
    88              "isRegistered": []
    89            },
    90            {
    91              "hasRole": [
    92                "inventoryManager"
    93              ],
    94              "isReseller": []
    95            },
    96            {
    97              "hasRole": [
    98                "inventoryManager"
    99              ],
   100              "isResellerQuery": []
   101            }
   102          ],
   103          "description": "Registered customers should be able to add purchase orders.\nRegistered inventory managers should be able to add replenishment orders.\n",
   104          "summary": "post a new order",
   105          "operationId": "AddOrder",
   106          "parameters": [
   107            {
   108              "name": "order",
   109              "in": "body",
   110              "required": true,
   111              "schema": {
   112                "$ref": "#/definitions/Order"
   113              }
   114            }
   115          ],
   116          "responses": {
   117            "200": {
   118              "description": "empty response"
   119            },
   120            "401": {
   121              "$ref": "#/responses/unauthorized"
   122            },
   123            "403": {
   124              "$ref": "#/responses/forbidden"
   125            },
   126            "default": {
   127              "$ref": "#/responses/otherError"
   128            }
   129          }
   130        }
   131      },
   132      "/order/{orderID}": {
   133        "get": {
   134          "security": [
   135            {
   136              "hasRole": [
   137                "customer"
   138              ],
   139              "isRegistered": []
   140            }
   141          ],
   142          "description": "Only registered customers should be able to retrieve orders\n",
   143          "summary": "retrieves an order",
   144          "operationId": "GetOrder",
   145          "parameters": [
   146            {
   147              "type": "string",
   148              "name": "orderID",
   149              "in": "path",
   150              "required": true
   151            }
   152          ],
   153          "responses": {
   154            "200": {
   155              "$ref": "#/responses/singleOrder"
   156            },
   157            "401": {
   158              "$ref": "#/responses/unauthorized"
   159            },
   160            "403": {
   161              "$ref": "#/responses/forbidden"
   162            },
   163            "default": {
   164              "$ref": "#/responses/otherError"
   165            }
   166          }
   167        }
   168      },
   169      "/orders/{itemID}": {
   170        "get": {
   171          "security": [
   172            {
   173              "isReseller": []
   174            },
   175            {
   176              "isResellerQuery": []
   177            }
   178          ],
   179          "description": "Only registered resellers should be able to search orders for an item\n",
   180          "summary": "retrieves all orders for an item",
   181          "operationId": "GetOrdersForItem",
   182          "parameters": [
   183            {
   184              "type": "string",
   185              "name": "itemID",
   186              "in": "path",
   187              "required": true
   188            }
   189          ],
   190          "responses": {
   191            "200": {
   192              "$ref": "#/responses/multipleOrders"
   193            },
   194            "401": {
   195              "$ref": "#/responses/unauthorized"
   196            },
   197            "403": {
   198              "$ref": "#/responses/forbidden"
   199            },
   200            "default": {
   201              "$ref": "#/responses/otherError"
   202            }
   203          }
   204        }
   205      }
   206    },
   207    "definitions": {
   208      "Error": {
   209        "type": "object",
   210        "required": [
   211          "message"
   212        ],
   213        "properties": {
   214          "code": {
   215            "type": "integer",
   216            "format": "int64"
   217          },
   218          "message": {
   219            "type": "string"
   220          }
   221        }
   222      },
   223      "Item": {
   224        "type": "string"
   225      },
   226      "Order": {
   227        "type": "object",
   228        "required": [
   229          "orderID"
   230        ],
   231        "properties": {
   232          "orderID": {
   233            "type": "string"
   234          },
   235          "orderLines": {
   236            "type": "array",
   237            "items": {
   238              "type": "object",
   239              "required": [
   240                "quantity",
   241                "purchasedItem"
   242              ],
   243              "properties": {
   244                "purchasedItem": {
   245                  "$ref": "#/definitions/Item"
   246                },
   247                "quantity": {
   248                  "type": "integer",
   249                  "format": "int32",
   250                  "minimum": 1
   251                }
   252              },
   253              "x-go-name": "orderLine"
   254            }
   255          }
   256        }
   257      },
   258      "principal": {
   259        "type": "object",
   260        "properties": {
   261          "name": {
   262            "type": "string"
   263          },
   264          "roles": {
   265            "type": "array",
   266            "items": {
   267              "type": "string"
   268            }
   269          }
   270        }
   271      }
   272    },
   273    "responses": {
   274      "forbidden": {
   275        "description": "forbidden access for a lack of sufficient privileges"
   276      },
   277      "multipleItems": {
   278        "description": "multiple items",
   279        "schema": {
   280          "type": "array",
   281          "items": {
   282            "$ref": "#/definitions/Item"
   283          }
   284        }
   285      },
   286      "multipleOrders": {
   287        "description": "multiple orders",
   288        "schema": {
   289          "type": "array",
   290          "items": {
   291            "$ref": "#/definitions/Order"
   292          }
   293        }
   294      },
   295      "otherError": {
   296        "description": "other error response",
   297        "schema": {
   298          "$ref": "#/definitions/Error"
   299        }
   300      },
   301      "singleItem": {
   302        "description": "single item",
   303        "schema": {
   304          "type": "string"
   305        }
   306      },
   307      "singleOrder": {
   308        "description": "content of an order",
   309        "schema": {
   310          "$ref": "#/definitions/Order"
   311        }
   312      },
   313      "unauthorized": {
   314        "description": "unauthorized access for a lack of authentication"
   315      }
   316    },
   317    "securityDefinitions": {
   318      "hasRole": {
   319        "type": "oauth2",
   320        "flow": "accessCode",
   321        "authorizationUrl": "https://dummy.oauth.net/auth",
   322        "tokenUrl": "https://dumy.oauth.net/token",
   323        "scopes": {
   324          "customer": "scope of registered customers",
   325          "inventoryManager": "scope of resellers acting as inventory managers"
   326        }
   327      },
   328      "isRegistered": {
   329        "type": "basic"
   330      },
   331      "isReseller": {
   332        "type": "apiKey",
   333        "name": "X-Custom-Key",
   334        "in": "header"
   335      },
   336      "isResellerQuery": {
   337        "type": "apiKey",
   338        "name": "CustomKeyAsQuery",
   339        "in": "query"
   340      }
   341    },
   342    "security": [
   343      {
   344        "isRegistered": null
   345      }
   346    ]
   347  }`))
   348  	FlatSwaggerJSON = json.RawMessage([]byte(`{
   349    "consumes": [
   350      "application/json"
   351    ],
   352    "produces": [
   353      "application/json"
   354    ],
   355    "schemes": [
   356      "http"
   357    ],
   358    "swagger": "2.0",
   359    "info": {
   360      "description": "This sample API demonstrates how to compose several authentication schemes\nand configure complex security requirements for your operations.\n\nThis API simulates a very simple market place with customers and resellers\nof items.\n\nPersonas:\n  - as a first time user, I want to see all items on sales\n  - as a registered customer, I want to post orders for items and\n    consult my past orders\n  - as a registered reseller, I want to see all pending orders on the items\n    I am selling on the market place\n  - as a reseller managing my own inventories, I want to post replenishment orders for the items I provide\n  - as a register user, I want to consult my personal account infos\n\nThe situation we defined on the authentication side is as follows:\n  - every known user is authenticated using a basic token\n  - resellers are authenticated using API keys - we let the option to authenticate using a header or query param\n  - any registered user (customer or reseller) will add a signed JWT to access more API endpoints\n\nObviously, there are several ways to achieve the same result. We just wanted to demonstrate here how\nsecurity requirements may compose several schemes.\n\nNote that we used the \"OAuth2\" declaration here but don't implement a real\nOAuth2 workflow: our intend here is just to be able to extract scopes from a passed JWT token (the\nonly way to manipulate scoped authorizers with Swagger 2.0 is to declare them with type \"oauth2\").\n",
   361      "title": "Composing authorizations",
   362      "version": "0.0.1"
   363    },
   364    "basePath": "/api",
   365    "paths": {
   366      "/account": {
   367        "get": {
   368          "security": [
   369            {
   370              "isRegistered": []
   371            }
   372          ],
   373          "description": "Every registered user should be able to access this operation\n",
   374          "summary": "registered user account",
   375          "operationId": "GetAccount",
   376          "responses": {
   377            "200": {
   378              "description": "registered user personal account infos",
   379              "schema": {
   380                "type": "object",
   381                "additionalProperties": true
   382              }
   383            },
   384            "401": {
   385              "description": "unauthorized access for a lack of authentication"
   386            },
   387            "default": {
   388              "description": "other error response",
   389              "schema": {
   390                "$ref": "#/definitions/Error"
   391              }
   392            }
   393          }
   394        }
   395      },
   396      "/items": {
   397        "get": {
   398          "security": [],
   399          "description": "Everybody should be able to access this operation\n",
   400          "summary": "items on sale",
   401          "operationId": "GetItems",
   402          "responses": {
   403            "200": {
   404              "description": "multiple items",
   405              "schema": {
   406                "type": "array",
   407                "items": {
   408                  "$ref": "#/definitions/Item"
   409                }
   410              }
   411            },
   412            "default": {
   413              "description": "other error response",
   414              "schema": {
   415                "$ref": "#/definitions/Error"
   416              }
   417            }
   418          }
   419        }
   420      },
   421      "/order/add": {
   422        "post": {
   423          "security": [
   424            {
   425              "hasRole": [
   426                "customer"
   427              ],
   428              "isRegistered": []
   429            },
   430            {
   431              "hasRole": [
   432                "inventoryManager"
   433              ],
   434              "isReseller": []
   435            },
   436            {
   437              "hasRole": [
   438                "inventoryManager"
   439              ],
   440              "isResellerQuery": []
   441            }
   442          ],
   443          "description": "Registered customers should be able to add purchase orders.\nRegistered inventory managers should be able to add replenishment orders.\n",
   444          "summary": "post a new order",
   445          "operationId": "AddOrder",
   446          "parameters": [
   447            {
   448              "name": "order",
   449              "in": "body",
   450              "required": true,
   451              "schema": {
   452                "$ref": "#/definitions/Order"
   453              }
   454            }
   455          ],
   456          "responses": {
   457            "200": {
   458              "description": "empty response"
   459            },
   460            "401": {
   461              "description": "unauthorized access for a lack of authentication"
   462            },
   463            "403": {
   464              "description": "forbidden access for a lack of sufficient privileges"
   465            },
   466            "default": {
   467              "description": "other error response",
   468              "schema": {
   469                "$ref": "#/definitions/Error"
   470              }
   471            }
   472          }
   473        }
   474      },
   475      "/order/{orderID}": {
   476        "get": {
   477          "security": [
   478            {
   479              "hasRole": [
   480                "customer"
   481              ],
   482              "isRegistered": []
   483            }
   484          ],
   485          "description": "Only registered customers should be able to retrieve orders\n",
   486          "summary": "retrieves an order",
   487          "operationId": "GetOrder",
   488          "parameters": [
   489            {
   490              "type": "string",
   491              "name": "orderID",
   492              "in": "path",
   493              "required": true
   494            }
   495          ],
   496          "responses": {
   497            "200": {
   498              "description": "content of an order",
   499              "schema": {
   500                "$ref": "#/definitions/Order"
   501              }
   502            },
   503            "401": {
   504              "description": "unauthorized access for a lack of authentication"
   505            },
   506            "403": {
   507              "description": "forbidden access for a lack of sufficient privileges"
   508            },
   509            "default": {
   510              "description": "other error response",
   511              "schema": {
   512                "$ref": "#/definitions/Error"
   513              }
   514            }
   515          }
   516        }
   517      },
   518      "/orders/{itemID}": {
   519        "get": {
   520          "security": [
   521            {
   522              "isReseller": []
   523            },
   524            {
   525              "isResellerQuery": []
   526            }
   527          ],
   528          "description": "Only registered resellers should be able to search orders for an item\n",
   529          "summary": "retrieves all orders for an item",
   530          "operationId": "GetOrdersForItem",
   531          "parameters": [
   532            {
   533              "type": "string",
   534              "name": "itemID",
   535              "in": "path",
   536              "required": true
   537            }
   538          ],
   539          "responses": {
   540            "200": {
   541              "description": "multiple orders",
   542              "schema": {
   543                "type": "array",
   544                "items": {
   545                  "$ref": "#/definitions/Order"
   546                }
   547              }
   548            },
   549            "401": {
   550              "description": "unauthorized access for a lack of authentication"
   551            },
   552            "403": {
   553              "description": "forbidden access for a lack of sufficient privileges"
   554            },
   555            "default": {
   556              "description": "other error response",
   557              "schema": {
   558                "$ref": "#/definitions/Error"
   559              }
   560            }
   561          }
   562        }
   563      }
   564    },
   565    "definitions": {
   566      "Error": {
   567        "type": "object",
   568        "required": [
   569          "message"
   570        ],
   571        "properties": {
   572          "code": {
   573            "type": "integer",
   574            "format": "int64"
   575          },
   576          "message": {
   577            "type": "string"
   578          }
   579        }
   580      },
   581      "Item": {
   582        "type": "string"
   583      },
   584      "Order": {
   585        "type": "object",
   586        "required": [
   587          "orderID"
   588        ],
   589        "properties": {
   590          "orderID": {
   591            "type": "string"
   592          },
   593          "orderLines": {
   594            "type": "array",
   595            "items": {
   596              "type": "object",
   597              "required": [
   598                "quantity",
   599                "purchasedItem"
   600              ],
   601              "properties": {
   602                "purchasedItem": {
   603                  "$ref": "#/definitions/Item"
   604                },
   605                "quantity": {
   606                  "type": "integer",
   607                  "format": "int32",
   608                  "minimum": 1
   609                }
   610              },
   611              "x-go-name": "orderLine"
   612            }
   613          }
   614        }
   615      },
   616      "principal": {
   617        "type": "object",
   618        "properties": {
   619          "name": {
   620            "type": "string"
   621          },
   622          "roles": {
   623            "type": "array",
   624            "items": {
   625              "type": "string"
   626            }
   627          }
   628        }
   629      }
   630    },
   631    "responses": {
   632      "forbidden": {
   633        "description": "forbidden access for a lack of sufficient privileges"
   634      },
   635      "multipleItems": {
   636        "description": "multiple items",
   637        "schema": {
   638          "type": "array",
   639          "items": {
   640            "$ref": "#/definitions/Item"
   641          }
   642        }
   643      },
   644      "multipleOrders": {
   645        "description": "multiple orders",
   646        "schema": {
   647          "type": "array",
   648          "items": {
   649            "$ref": "#/definitions/Order"
   650          }
   651        }
   652      },
   653      "otherError": {
   654        "description": "other error response",
   655        "schema": {
   656          "$ref": "#/definitions/Error"
   657        }
   658      },
   659      "singleItem": {
   660        "description": "single item",
   661        "schema": {
   662          "type": "string"
   663        }
   664      },
   665      "singleOrder": {
   666        "description": "content of an order",
   667        "schema": {
   668          "$ref": "#/definitions/Order"
   669        }
   670      },
   671      "unauthorized": {
   672        "description": "unauthorized access for a lack of authentication"
   673      }
   674    },
   675    "securityDefinitions": {
   676      "hasRole": {
   677        "type": "oauth2",
   678        "flow": "accessCode",
   679        "authorizationUrl": "https://dummy.oauth.net/auth",
   680        "tokenUrl": "https://dumy.oauth.net/token",
   681        "scopes": {
   682          "customer": "scope of registered customers",
   683          "inventoryManager": "scope of resellers acting as inventory managers"
   684        }
   685      },
   686      "isRegistered": {
   687        "type": "basic"
   688      },
   689      "isReseller": {
   690        "type": "apiKey",
   691        "name": "X-Custom-Key",
   692        "in": "header"
   693      },
   694      "isResellerQuery": {
   695        "type": "apiKey",
   696        "name": "CustomKeyAsQuery",
   697        "in": "query"
   698      }
   699    },
   700    "security": [
   701      {
   702        "isRegistered": []
   703      }
   704    ]
   705  }`))
   706  }