From 18fc08eeaf91c461c52ecf85c0a09c2576b4aada Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Sat, 4 Aug 2018 18:02:45 +0500 Subject: [PATCH 01/20] Add example of swagger annotations --- api.go | 87 +++++++++++++++++++++++++++++++++++++++ apidef/api_definitions.go | 2 + 2 files changed, 89 insertions(+) diff --git a/api.go b/api.go index 7f2ca58da9f..ded525d3473 100644 --- a/api.go +++ b/api.go @@ -1,3 +1,27 @@ +// Tyk Gateway API +// +// Code below describes Tyk Gateway API +// +// Schemes: http, https +// Host: localhost +// BasePath: /tyk/ +// +// Consumes: +// - application/json +// +// Produces: +// - application/json +// +// Security: +// - api_key: +// +// SecurityDefinitions: +// api_key: +// type: apiKey +// name: X-Tyk-Authorization +// in: header +// +// swagger:meta package main import ( @@ -28,6 +52,8 @@ import ( ) // apiModifyKeySuccess represents when a Key modification was successful +// +// swagger:response type apiModifyKeySuccess struct { Key string `json:"key"` Status string `json:"status"` @@ -36,8 +62,12 @@ type apiModifyKeySuccess struct { } // apiStatusMessage represents an API status message +// +// swagger:response type apiStatusMessage struct { + // Status can be either `ok` or `error` Status string `json:"status"` + // Response details Message string `json:"message"` } @@ -732,6 +762,50 @@ func handleDeleteAPI(apiID string) (interface{}, int) { return response, http.StatusOK } +// swagger:route GET /apis apis listApis +// +// List APIs +// Only if used without dashboard +//--- +// responses: +// 200: +// description: List of API definitions +// schema: +// type: array +// items: +// "$ref": "#/definitions/APIDefinition" + +// swagger:route POST /apis apis createApi +// +// Create API +// +// responses: +// '200': +// description: API created +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "created" +// key: "{...API JSON definition...}" +// '400': +// description: Malformed data +// schema: +// "$ref": "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Malformed API data" + +// swagger:route GET /apis/{apiID} apis getApi +// +// Get API +// Only if used without dashboard +// +// Responses: +// 200: +// description: API definition +// schema: +// $ref: "#/definitions/APIDefinition" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] @@ -1081,6 +1155,12 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { return statusObj, http.StatusOK } +// swagger:route GET /reload/group reloadGroup +// +// Reload all gateways in cluser +// +// Responses: +// 200: apiStatusMessage func groupResetHandler(w http.ResponseWriter, r *http.Request) { log.WithFields(logrus.Fields{ "prefix": "api", @@ -1101,6 +1181,13 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // was in the URL parameters, it will block until the reload is done. // Otherwise, it won't block and fn will be called once the reload is // finished. +// +// swagger:route GET /reload reload +// +// Reload single gateway instance +// +// Responses: +// 200: apiStatusMessage func resetHandler(fn func()) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var wg sync.WaitGroup diff --git a/apidef/api_definitions.go b/apidef/api_definitions.go index c88e4243c3a..44f66312030 100644 --- a/apidef/api_definitions.go +++ b/apidef/api_definitions.go @@ -330,6 +330,8 @@ type OpenIDOptions struct { } // APIDefinition represents the configuration for a single proxied API and it's versions. +// +// swagger:model type APIDefinition struct { Id bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"` Name string `bson:"name" json:"name"` From c9701eb37e2db6108be730be1547d4f390785176 Mon Sep 17 00:00:00 2001 From: marksou Date: Tue, 28 Aug 2018 12:48:10 +0100 Subject: [PATCH 02/20] Added deleteApi section and also added gateway version --- api.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/api.go b/api.go index ded525d3473..2f2b51621a0 100644 --- a/api.go +++ b/api.go @@ -1,6 +1,7 @@ // Tyk Gateway API // // Code below describes Tyk Gateway API +// version: 1.7.0 // // Schemes: http, https // Host: localhost @@ -806,6 +807,27 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // description: API definition // schema: // $ref: "#/definitions/APIDefinition" + +// swagger:route DELETE /apis/{apiID} apis deleteApi +// +// Delete API +// Only if used without dashboard +// +// Responses: +// '200': +// description: API deleted +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "ok" +// message: "API deleted" +// '400': +// description: No API ID specified +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "API ID not specified" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] From 433ef1f235c1bc8de4d63848a96b7a2e57bafdc5 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Tue, 28 Aug 2018 19:11:50 +0300 Subject: [PATCH 03/20] Fix goswagger annotations to work with examples --- api.go | 154 +++++++++++++++++++++++++++++++++++------------- user/session.go | 1 + 2 files changed, 113 insertions(+), 42 deletions(-) diff --git a/api.go b/api.go index 2f2b51621a0..cd587fc5dd8 100644 --- a/api.go +++ b/api.go @@ -67,7 +67,7 @@ type apiModifyKeySuccess struct { // swagger:response type apiStatusMessage struct { // Status can be either `ok` or `error` - Status string `json:"status"` + Status string `json:"status"` // Response details Message string `json:"message"` } @@ -763,10 +763,11 @@ func handleDeleteAPI(apiID string) (interface{}, int) { return response, http.StatusOK } -// swagger:route GET /apis apis listApis +// swagger:operation GET /apis apis listApis // // List APIs // Only if used without dashboard +// //--- // responses: // 200: @@ -776,58 +777,61 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // items: // "$ref": "#/definitions/APIDefinition" -// swagger:route POST /apis apis createApi +// swagger:operation POST /apis apis createApi // // Create API // -// responses: -// '200': -// description: API created -// schema: -// "$ref": "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "created" -// key: "{...API JSON definition...}" -// '400': -// description: Malformed data -// schema: -// "$ref": "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Malformed API data" - -// swagger:route GET /apis/{apiID} apis getApi +//--- +// responses: +// 200: +// description: API created +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "created" +// key: "{...API JSON definition...}" +// 400: +// description: Malformed data +// schema: +// "$ref": "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Malformed API data" + +// swagger:operation GET /apis/{apiID} apis getApi // // Get API // Only if used without dashboard // -// Responses: -// 200: -// description: API definition -// schema: -// $ref: "#/definitions/APIDefinition" +//--- +// responses: +// 200: +// description: API definition +// schema: +// $ref: "#/definitions/APIDefinition" -// swagger:route DELETE /apis/{apiID} apis deleteApi +// swagger:operation DELETE /apis/{apiID} apis deleteApi // // Delete API // Only if used without dashboard // -// Responses: -// '200': -// description: API deleted -// schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "ok" -// message: "API deleted" -// '400': -// description: No API ID specified -// schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "API ID not specified" +//--- +// responses: +// 200: +// description: API deleted +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "ok" +// message: "API deleted" +// 400: +// description: No API ID specified +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "API ID not specified" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] @@ -865,6 +869,72 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } +// swagger:operation GET /keys keys listKeys +// +// List Keys +// +//--- +// responses: +// 200: +// description: List of API keys +// schema: +// type: array +// items: +// type: string + +// swagger:operation POST /keys keys createKey +// +// Create Key +// +//--- +// responses: +// 200: +// description: Key created +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "created" +// key: "{...KEY JSON definition...}" +// 400: +// description: Malformed data +// schema: +// "$ref": "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Malformed Key data" + +// swagger:operation GET /keys/{keyID} keys getKey +// +// Get Key +// +//--- +// responses: +// 200: +// description: Key object +// schema: +// $ref: "#/definitions/SessionState" + +// swagger:operation DELETE /keys/{keyID} keys deleteKey +// +// Delete Key +// +//--- +// responses: +// 200: +// description: Key deleted +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "ok" +// message: "Key deleted" +// 400: +// description: No Key ID specified +// schema: +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Key ID not specified" func keyHandler(w http.ResponseWriter, r *http.Request) { keyName := mux.Vars(r)["keyName"] apiID := r.URL.Query().Get("api_id") diff --git a/user/session.go b/user/session.go index 6ce9115f89b..4739ee2291c 100644 --- a/user/session.go +++ b/user/session.go @@ -44,6 +44,7 @@ type AccessDefinition struct { // SessionState objects represent a current API session, mainly used for rate limiting. // There's a data structure that's based on this and it's used for Protocol Buffer support, make sure to update "coprocess/proto/coprocess_session_state.proto" and generate the bindings using: cd coprocess/proto && ./update_bindings.sh +// swagger:model type SessionState struct { LastCheck int64 `json:"last_check" msg:"last_check"` Allowance float64 `json:"allowance" msg:"allowance"` From 39e8b2dc96c4f88b168311777943edab8bf14cc8 Mon Sep 17 00:00:00 2001 From: marksou Date: Thu, 30 Aug 2018 12:35:32 +0100 Subject: [PATCH 04/20] Update API, Keys and Reload Swagger sections --- api.go | 122 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 100 insertions(+), 22 deletions(-) diff --git a/api.go b/api.go index cd587fc5dd8..c15f0e62dcf 100644 --- a/api.go +++ b/api.go @@ -1,7 +1,7 @@ // Tyk Gateway API // -// Code below describes Tyk Gateway API -// version: 1.7.0 +// The code below describes the Tyk Gateway API +// Version: 1.7.0 // // Schemes: http, https // Host: localhost @@ -763,10 +763,10 @@ func handleDeleteAPI(apiID string) (interface{}, int) { return response, http.StatusOK } -// swagger:operation GET /apis apis listApis +// swagger:operation GET /apis APIs listApis // // List APIs -// Only if used without dashboard +// Only if used without the Tyk Dashboard // //--- // responses: @@ -777,7 +777,7 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // items: // "$ref": "#/definitions/APIDefinition" -// swagger:operation POST /apis apis createApi +// swagger:operation POST /apis APIs createApi // // Create API // @@ -799,24 +799,38 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // status: "error" // message: "Malformed API data" -// swagger:operation GET /apis/{apiID} apis getApi +// swagger:operation GET /apis/{apiID} APIs getApi // // Get API -// Only if used without dashboard +// Only if used without the Tyk Dashboard // //--- +// parameters: +// - in: path +// name: apiID +// required: true +// type: integer +// minimum: 1 +// description: The API ID // responses: // 200: // description: API definition // schema: // $ref: "#/definitions/APIDefinition" -// swagger:operation DELETE /apis/{apiID} apis deleteApi +// swagger:operation DELETE /apis/{apiID} APIs deleteApi // // Delete API -// Only if used without dashboard +// Only if used without the Tyk Dashboard // //--- +// parameters: +// - in: path +// name: apiID +// required: true +// type: integer +// minimum: 1 +// description: The API ID // responses: // 200: // description: API deleted @@ -869,27 +883,27 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } -// swagger:operation GET /keys keys listKeys +// swagger:operation GET /keys Keys listKeys // -// List Keys +// List All Keys // //--- // responses: // 200: -// description: List of API keys +// description: List of all API keys // schema: // type: array // items: // type: string -// swagger:operation POST /keys keys createKey +// swagger:operation POST /keys Keys createKey // -// Create Key +// Create a new Key // //--- // responses: // 200: -// description: Key created +// description: New Key created // schema: // "$ref": "#/responses/apiModifyKeySuccess" // examples: @@ -904,22 +918,86 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // status: "error" // message: "Malformed Key data" -// swagger:operation GET /keys/{keyID} keys getKey +// swagger:operation POST /keys Keys addKey // -// Get Key +// Add an existing Key // //--- // responses: // 200: +// description: New Key added +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "created" +// key: "{...KEY JSON definition...}" +// 400: +// description: Malformed data +// schema: +// "$ref": "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Malformed Key data" + +// swagger:operation PUT /keys/{keyID} Keys updateKey +// +// Update a Key +// +//--- +// parameters: +// - in: path +// name: keyID +// required: true +// type: integer +// minimum: 1 +// description: The Key ID +// responses: +// 200: +// description: Key updated +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "updated" +// 400: +// description: No or incorrect Key ID specified +// schema: +// "$ref": "#/responses/apiStatusMessage" +// examples: +// status: "error" +// message: "Key ID not specified" + +// swagger:operation GET /keys/{keyID} Keys getKey +// +// Get a Key +// +//--- +// parameters: +// - in: path +// name: keyID +// required: true +// type: integer +// minimum: 1 +// description: The Key ID +// responses: +// 200: // description: Key object // schema: // $ref: "#/definitions/SessionState" -// swagger:operation DELETE /keys/{keyID} keys deleteKey +// swagger:operation DELETE /keys/{keyID} Keys deleteKey // // Delete Key // //--- +// parameters: +// - in: path +// name: keyID +// required: true +// type: integer +// minimum: 1 +// description: The Key ID // responses: // 200: // description: Key deleted @@ -1247,9 +1325,9 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { return statusObj, http.StatusOK } -// swagger:route GET /reload/group reloadGroup +// swagger:route GET /reload/group Reload reloadGroup // -// Reload all gateways in cluser +// Reloads all the Tyk Gateways in a cluster // // Responses: // 200: apiStatusMessage @@ -1274,9 +1352,9 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // Otherwise, it won't block and fn will be called once the reload is // finished. // -// swagger:route GET /reload reload +// swagger:route GET /reload Reload reload // -// Reload single gateway instance +// Reloads a single Tyk Gateway instance // // Responses: // 200: apiStatusMessage From 9b04fd07ce70e97dbf81bc4db5135da04160617c Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Thu, 6 Sep 2018 22:11:08 +0300 Subject: [PATCH 05/20] Add swagger docs for oAuth and cache invalidation --- api.go | 165 +++++++++++++++++++++++++++++++++++++++++++++++ oauth_manager.go | 2 + 2 files changed, 167 insertions(+) diff --git a/api.go b/api.go index c15f0e62dcf..e1ce30f6713 100644 --- a/api.go +++ b/api.go @@ -1512,6 +1512,8 @@ func createKeyHandler(w http.ResponseWriter, r *http.Request) { } // NewClientRequest is an outward facing JSON object translated from osin OAuthClients +// +// swagger:model type NewClientRequest struct { ClientID string `json:"client_id"` ClientRedirectURI string `json:"redirect_uri"` @@ -1526,6 +1528,25 @@ func oauthClientStorageID(clientID string) string { return prefixClient + clientID } +// swagger:operation POST /oauth/clients/create oauth createOAuthClient +// +// Create oAuth client +// +//--- +// requestBody: +// content: +// application/json: +// schema: +// "$ref": "#/definitions/NewClientRequest" +// examples: +// client_id: test +// api_id: id +// policy_id: policy +// responses: +// 200: +// description: Client created +// schema: +// "$ref": "#/responses/OAuthClient" func createOauthClient(w http.ResponseWriter, r *http.Request) { var newOauthClient NewClientRequest if err := json.NewDecoder(r.Body).Decode(&newOauthClient); err != nil { @@ -1740,6 +1761,38 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int return replyData, http.StatusOK } +// swagger:operation DELETE /oauth/refresh/{keyName} oauth invalidateOAuthRefresh +// +// Invalidate oAuth refresh token +// +//--- +// parameters: +// - in: query +// name: api_id +// required: true +// schema: +// type: string +// description: API id +// - in: path +// name: keyName +// required: true +// schema: +// type: string +// description: Refresh token +// requestBody: +// content: +// application/json: +// schema: +// "$ref": "#/definitions/NewClientRequest" +// examples: +// client_id: test +// api_id: id +// policy_id: policy +// responses: +// 200: +// description: Deleted +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { apiID := r.URL.Query().Get("api_id") if apiID == "" { @@ -1807,6 +1860,76 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, success) } +// swagger:operation GET /oauth/clients/{apiID} oauth listOAuthClients +// +// List oAuth client +// +//--- +// parameters: +// - in: path +// name: apiID +// required: true +// schema: +// type: string +// description: API ID +// responses: +// 200: +// description: Get client details or list of clients +// schema: +// type: array +// items: +// "$ref": "#/responses/NewClientRequest" + +// swagger:operation GET /oauth/clients/{apiID}/{keyName} oauth getOAuthClient +// +// Get oAuth client +// +//--- +// parameters: +// - in: path +// name: apiID +// required: true +// schema: +// type: string +// description: API ID +// - in: path +// name: keyName +// required: true +// schema: +// type: string +// description: Client ID +// responses: +// 200: +// description: Get client details or list of clients +// schema: +// "$ref": "#/responses/NewClientRequest" + +// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} oauth deleteOAuthClient +// +// Delete oAuth client +// +//--- +// parameters: +// - in: path +// name: apiID +// required: true +// schema: +// type: string +// description: API ID +// - in: path +// name: keyName +// required: true +// schema: +// type: string +// description: Client ID +// responses: +// 200: +// description: oAuth client deleted +// schema: +// "$ref": "#/responses/apiModifyKeySuccess" +// examples: +// status: "ok" +// action: "deleted" func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -1833,6 +1956,31 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } +// swagger:operation GET /oauth/clients/{apiID}/{keyName}/tokens oauth getOAuthClientTokens +// +// Get oAuth client tokens +// +//--- +// parameters: +// - in: path +// name: apiID +// required: true +// schema: +// type: string +// description: API ID +// - in: path +// name: keyName +// required: true +// schema: +// type: string +// description: Client ID +// responses: +// 200: +// description: Get list of tokens +// schema: +// type: array +// items: +// type: string func oAuthClientTokensHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -2035,6 +2183,23 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, returnSession) } +// swagger:operation DELETE /cache/{apiID} cache invalidateCache +// +// Invalidate cache +// +//--- +// parameters: +// - in: path +// name: apiID +// required: true +// schema: +// type: string +// description: API ID +// responses: +// 200: +// description: Invalidate cache +// schema: +// "$ref": "#/responses/apiOk" func invalidateCacheHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] diff --git a/oauth_manager.go b/oauth_manager.go index 2453c3cd87c..f619a4b2083 100644 --- a/oauth_manager.go +++ b/oauth_manager.go @@ -40,6 +40,8 @@ Effort required by Resource Owner: */ // OAuthClient is a representation within an APISpec of a client +// +// swagger:model type OAuthClient struct { ClientID string `json:"id"` ClientSecret string `json:"secret"` From 74b1b63f261c04834da51766daeedb8b963d15f4 Mon Sep 17 00:00:00 2001 From: Leonid Bugaev Date: Fri, 7 Sep 2018 14:46:39 +0300 Subject: [PATCH 06/20] Fix swagger issue --- api.go | 2 +- oauth_manager.go | 2 -- user/session.go | 1 + 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index e1ce30f6713..3d469c15968 100644 --- a/api.go +++ b/api.go @@ -1546,7 +1546,7 @@ func oauthClientStorageID(clientID string) string { // 200: // description: Client created // schema: -// "$ref": "#/responses/OAuthClient" +// "$ref": "#/responses/NewClientRequest" func createOauthClient(w http.ResponseWriter, r *http.Request) { var newOauthClient NewClientRequest if err := json.NewDecoder(r.Body).Decode(&newOauthClient); err != nil { diff --git a/oauth_manager.go b/oauth_manager.go index f619a4b2083..2453c3cd87c 100644 --- a/oauth_manager.go +++ b/oauth_manager.go @@ -40,8 +40,6 @@ Effort required by Resource Owner: */ // OAuthClient is a representation within an APISpec of a client -// -// swagger:model type OAuthClient struct { ClientID string `json:"id"` ClientSecret string `json:"secret"` diff --git a/user/session.go b/user/session.go index 4739ee2291c..b13dfe05920 100644 --- a/user/session.go +++ b/user/session.go @@ -44,6 +44,7 @@ type AccessDefinition struct { // SessionState objects represent a current API session, mainly used for rate limiting. // There's a data structure that's based on this and it's used for Protocol Buffer support, make sure to update "coprocess/proto/coprocess_session_state.proto" and generate the bindings using: cd coprocess/proto && ./update_bindings.sh +// // swagger:model type SessionState struct { LastCheck int64 `json:"last_check" msg:"last_check"` From 6a818281f11c27b7c6a63fe3d458a79f8aff9896 Mon Sep 17 00:00:00 2001 From: marksou Date: Fri, 7 Sep 2018 12:57:37 +0100 Subject: [PATCH 07/20] updates before new pull --- api.go | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/api.go b/api.go index 3d469c15968..3b1cc334f42 100644 --- a/api.go +++ b/api.go @@ -809,7 +809,7 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // - in: path // name: apiID // required: true -// type: integer +// type: string // minimum: 1 // description: The API ID // responses: @@ -828,7 +828,7 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // - in: path // name: apiID // required: true -// type: integer +// type: string // minimum: 1 // description: The API ID // responses: @@ -949,7 +949,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // - in: path // name: keyID // required: true -// type: integer +// type: string // minimum: 1 // description: The Key ID // responses: @@ -977,7 +977,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // - in: path // name: keyID // required: true -// type: integer +// type: string // minimum: 1 // description: The Key ID // responses: @@ -995,7 +995,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // - in: path // name: keyID // required: true -// type: integer +// type: string // minimum: 1 // description: The Key ID // responses: @@ -1528,9 +1528,9 @@ func oauthClientStorageID(clientID string) string { return prefixClient + clientID } -// swagger:operation POST /oauth/clients/create oauth createOAuthClient +// swagger:operation POST /oauth/clients/create OAuth createOAuthClient // -// Create oAuth client +// Create an OAuth client // //--- // requestBody: @@ -1772,7 +1772,7 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // required: true // schema: // type: string -// description: API id +// description: The API id // - in: path // name: keyName // required: true @@ -1860,9 +1860,9 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, success) } -// swagger:operation GET /oauth/clients/{apiID} oauth listOAuthClients +// swagger:operation GET /oauth/clients/{apiID} OAuth listOAuthClients // -// List oAuth client +// List oAuth clients // //--- // parameters: @@ -1871,18 +1871,18 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // required: true // schema: // type: string -// description: API ID +// description: The API ID // responses: // 200: -// description: Get client details or list of clients +// description: Get OAuth client details or a list of OAuth clients // schema: // type: array // items: // "$ref": "#/responses/NewClientRequest" -// swagger:operation GET /oauth/clients/{apiID}/{keyName} oauth getOAuthClient +// swagger:operation GET /oauth/clients/{apiID}/{keyName} OAuth getOAuthClient // -// Get oAuth client +// Get OAuth client // //--- // parameters: @@ -1897,10 +1897,10 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // required: true // schema: // type: string -// description: Client ID +// description: The Client ID // responses: // 200: -// description: Get client details or list of clients +// description: Get OAuth client details or a list of OAuth clients // schema: // "$ref": "#/responses/NewClientRequest" @@ -1915,16 +1915,16 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // required: true // schema: // type: string -// description: API ID +// description: The API ID // - in: path // name: keyName // required: true // schema: // type: string -// description: Client ID +// description: The Client ID // responses: // 200: -// description: oAuth client deleted +// description: OAuth client deleted // schema: // "$ref": "#/responses/apiModifyKeySuccess" // examples: @@ -1956,9 +1956,9 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } -// swagger:operation GET /oauth/clients/{apiID}/{keyName}/tokens oauth getOAuthClientTokens +// swagger:operation GET /oauth/clients/{apiID}/{keyName}/tokens OAuth getOAuthClientTokens // -// Get oAuth client tokens +// Get OAuth client tokens // //--- // parameters: @@ -1967,16 +1967,16 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { // required: true // schema: // type: string -// description: API ID +// description: The API ID // - in: path // name: keyName // required: true // schema: // type: string -// description: Client ID +// description: The Client ID // responses: // 200: -// description: Get list of tokens +// description: Get a list of tokens // schema: // type: array // items: @@ -2183,7 +2183,7 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, returnSession) } -// swagger:operation DELETE /cache/{apiID} cache invalidateCache +// swagger:operation DELETE /cache/{apiID} Cache invalidateCache // // Invalidate cache // @@ -2194,7 +2194,7 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { // required: true // schema: // type: string -// description: API ID +// description: The API ID // responses: // 200: // description: Invalidate cache From 14ff57d6df11cbd4bb341d3503728ee7adf54b45 Mon Sep 17 00:00:00 2001 From: marksou Date: Fri, 7 Sep 2018 16:47:34 +0100 Subject: [PATCH 08/20] Updated OAuth and Invalidate Cache sections --- api.go | 149 +++++++++++++++++++++++++++------------------------------ 1 file changed, 70 insertions(+), 79 deletions(-) diff --git a/api.go b/api.go index 3b1cc334f42..73c15e0c17a 100644 --- a/api.go +++ b/api.go @@ -810,7 +810,6 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // name: apiID // required: true // type: string -// minimum: 1 // description: The API ID // responses: // 200: @@ -829,7 +828,6 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // name: apiID // required: true // type: string -// minimum: 1 // description: The API ID // responses: // 200: @@ -905,7 +903,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: New Key created // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// $ref: "#/responses/apiModifyKeySuccess" // examples: // status: "ok" // action: "created" @@ -913,7 +911,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 400: // description: Malformed data // schema: -// "$ref": "#/responses/apiStatusMessage" +// $ref: "#/responses/apiStatusMessage" // examples: // status: "error" // message: "Malformed Key data" @@ -927,7 +925,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: New Key added // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// $ref: "#/responses/apiModifyKeySuccess" // examples: // status: "ok" // action: "created" @@ -935,7 +933,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 400: // description: Malformed data // schema: -// "$ref": "#/responses/apiStatusMessage" +// $ref: "#/responses/apiStatusMessage" // examples: // status: "error" // message: "Malformed Key data" @@ -950,7 +948,6 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // name: keyID // required: true // type: string -// minimum: 1 // description: The Key ID // responses: // 200: @@ -963,7 +960,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 400: // description: No or incorrect Key ID specified // schema: -// "$ref": "#/responses/apiStatusMessage" +// $ref: "#/responses/apiStatusMessage" // examples: // status: "error" // message: "Key ID not specified" @@ -978,7 +975,6 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // name: keyID // required: true // type: string -// minimum: 1 // description: The Key ID // responses: // 200: @@ -996,7 +992,6 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // name: keyID // required: true // type: string -// minimum: 1 // description: The Key ID // responses: // 200: @@ -1537,7 +1532,7 @@ func oauthClientStorageID(clientID string) string { // content: // application/json: // schema: -// "$ref": "#/definitions/NewClientRequest" +// $ref: "#/definitions/NewClientRequest" // examples: // client_id: test // api_id: id @@ -1546,7 +1541,7 @@ func oauthClientStorageID(clientID string) string { // 200: // description: Client created // schema: -// "$ref": "#/responses/NewClientRequest" +// $ref: "#/definitions/NewClientRequest" func createOauthClient(w http.ResponseWriter, r *http.Request) { var newOauthClient NewClientRequest if err := json.NewDecoder(r.Body).Decode(&newOauthClient); err != nil { @@ -1763,22 +1758,20 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // swagger:operation DELETE /oauth/refresh/{keyName} oauth invalidateOAuthRefresh // -// Invalidate oAuth refresh token +// Invalidate OAuth refresh token // //--- // parameters: -// - in: query -// name: api_id -// required: true -// schema: -// type: string -// description: The API id -// - in: path -// name: keyName -// required: true -// schema: -// type: string -// description: Refresh token +// - in: query +// name: api_id +// required: true +// type: string +// description: The API id +// - in: path +// name: keyName +// required: true +// type: string +// description: Refresh token // requestBody: // content: // application/json: @@ -1792,7 +1785,7 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // 200: // description: Deleted // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { apiID := r.URL.Query().Get("api_id") if apiID == "" { @@ -1862,23 +1855,22 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /oauth/clients/{apiID} OAuth listOAuthClients // -// List oAuth clients +// List OAuth clients // //--- // parameters: -// - in: path -// name: apiID -// required: true -// schema: -// type: string -// description: The API ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID // responses: // 200: // description: Get OAuth client details or a list of OAuth clients // schema: // type: array // items: -// "$ref": "#/responses/NewClientRequest" +// "$ref": "#/definitions/NewClientRequest" // swagger:operation GET /oauth/clients/{apiID}/{keyName} OAuth getOAuthClient // @@ -1886,42 +1878,40 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// schema: -// type: string -// description: API ID -// - in: path -// name: keyName -// required: true -// schema: -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// minimum: 1 +// description: The API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: Get OAuth client details or a list of OAuth clients // schema: -// "$ref": "#/responses/NewClientRequest" +// "$ref": "#/definitions/NewClientRequest" -// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} oauth deleteOAuthClient +// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} OAuth deleteOAuthClient // // Delete oAuth client // //--- // parameters: -// - in: path -// name: apiID -// required: true -// schema: -// type: string -// description: The API ID -// - in: path -// name: keyName -// required: true -// schema: -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// minimum: 1 +// description: The API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: OAuth client deleted @@ -1962,18 +1952,17 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// schema: -// type: string -// description: The API ID -// - in: path -// name: keyName -// required: true -// schema: -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// minimum: 1 +// description: The API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: Get a list of tokens @@ -2189,17 +2178,19 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// schema: -// type: string -// description: The API ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID // responses: // 200: // description: Invalidate cache // schema: -// "$ref": "#/responses/apiOk" +// $ref: "#/responses/apiStatusMessage" +// examples: +// status: "ok" +// message: "cache invalidated" func invalidateCacheHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] From 1f3a408ec79c03ddc6676129867c7dd828b5e345 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 10:19:17 +0100 Subject: [PATCH 09/20] generation works now little working version passes generation and validation --- api.go | 226 ++++++++++++++++++++--------------------------------- swagger.go | 21 +++++ tracing.go | 12 +-- 3 files changed, 109 insertions(+), 150 deletions(-) create mode 100644 swagger.go diff --git a/api.go b/api.go index 73c15e0c17a..1c10351b48f 100644 --- a/api.go +++ b/api.go @@ -1,7 +1,7 @@ // Tyk Gateway API // // The code below describes the Tyk Gateway API -// Version: 1.7.0 +// Version: 2.8.0 // // Schemes: http, https // Host: localhost @@ -54,8 +54,9 @@ import ( // apiModifyKeySuccess represents when a Key modification was successful // -// swagger:response +// swagger:response apiModifyKeySuccess type apiModifyKeySuccess struct { + // in:body Key string `json:"key"` Status string `json:"status"` Action string `json:"action"` @@ -64,9 +65,8 @@ type apiModifyKeySuccess struct { // apiStatusMessage represents an API status message // -// swagger:response +// swagger:response apiStatusMessage type apiStatusMessage struct { - // Status can be either `ok` or `error` Status string `json:"status"` // Response details Message string `json:"message"` @@ -787,17 +787,10 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // description: API created // schema: // "$ref": "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "created" -// key: "{...API JSON definition...}" // 400: // description: Malformed data // schema: // "$ref": "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Malformed API data" // swagger:operation GET /apis/{apiID} APIs getApi // @@ -834,16 +827,10 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // description: API deleted // schema: // $ref: "#/responses/apiStatusMessage" -// examples: -// status: "ok" -// message: "API deleted" // 400: // description: No API ID specified // schema: // $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "API ID not specified" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] @@ -883,7 +870,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /keys Keys listKeys // -// List All Keys +// List all keys // //--- // responses: @@ -896,25 +883,18 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation POST /keys Keys createKey // -// Create a new Key +// Create a new key // //--- // responses: // 200: // description: New Key created // schema: -// $ref: "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "created" -// key: "{...KEY JSON definition...}" +// "$ref": "#/responses/apiModifyKeySuccess" // 400: // description: Malformed data // schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Malformed Key data" +// "$ref": "#/responses/apiStatusMessage" // swagger:operation POST /keys Keys addKey // @@ -925,18 +905,11 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: New Key added // schema: -// $ref: "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "created" -// key: "{...KEY JSON definition...}" +// "$ref": "#/responses/apiModifyKeySuccess" // 400: // description: Malformed data // schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Malformed Key data" +// "$ref": "#/responses/apiStatusMessage" // swagger:operation PUT /keys/{keyID} Keys updateKey // @@ -954,20 +927,14 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // description: Key updated // schema: // "$ref": "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "updated" // 400: // description: No or incorrect Key ID specified // schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Key ID not specified" +// "$ref": "#/responses/apiStatusMessage" // swagger:operation GET /keys/{keyID} Keys getKey // -// Get a Key +// Get a key // //--- // parameters: @@ -984,7 +951,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation DELETE /keys/{keyID} Keys deleteKey // -// Delete Key +// Delete a key // //--- // parameters: @@ -998,16 +965,10 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // description: Key deleted // schema: // $ref: "#/responses/apiStatusMessage" -// examples: -// status: "ok" -// message: "Key deleted" // 400: // description: No Key ID specified // schema: // $ref: "#/responses/apiStatusMessage" -// examples: -// status: "error" -// message: "Key ID not specified" func keyHandler(w http.ResponseWriter, r *http.Request) { keyName := mux.Vars(r)["keyName"] apiID := r.URL.Query().Get("api_id") @@ -1320,12 +1281,14 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { return statusObj, http.StatusOK } -// swagger:route GET /reload/group Reload reloadGroup -// -// Reloads all the Tyk Gateways in a cluster -// -// Responses: -// 200: apiStatusMessage +// swagger:operation GET /reload/group Reload reloadGroup +// --- +// summary: Reloads all the Tyk Gateways in a cluster +// responses: +// "200": +// description: All gateways in a cluster were successfully refreshed +// schema: +// "$ref": "#/responses/apiStatusMessage" func groupResetHandler(w http.ResponseWriter, r *http.Request) { log.WithFields(logrus.Fields{ "prefix": "api", @@ -1508,7 +1471,7 @@ func createKeyHandler(w http.ResponseWriter, r *http.Request) { // NewClientRequest is an outward facing JSON object translated from osin OAuthClients // -// swagger:model +// swagger:model NewClientRequest type NewClientRequest struct { ClientID string `json:"client_id"` ClientRedirectURI string `json:"redirect_uri"` @@ -1528,20 +1491,17 @@ func oauthClientStorageID(clientID string) string { // Create an OAuth client // //--- -// requestBody: -// content: -// application/json: -// schema: -// $ref: "#/definitions/NewClientRequest" -// examples: -// client_id: test -// api_id: id -// policy_id: policy +// parameters: +// - in: body +// name: client_info +// required: true +// schema: +// "$ref": "#/definitions/NewClientRequest" // responses: // 200: // description: Client created // schema: -// $ref: "#/definitions/NewClientRequest" +// "$ref": "#/definitions/NewClientRequest" func createOauthClient(w http.ResponseWriter, r *http.Request) { var newOauthClient NewClientRequest if err := json.NewDecoder(r.Body).Decode(&newOauthClient); err != nil { @@ -1758,34 +1718,25 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // swagger:operation DELETE /oauth/refresh/{keyName} oauth invalidateOAuthRefresh // -// Invalidate OAuth refresh token +// Invalidate oAuth refresh token // //--- // parameters: -// - in: query -// name: api_id -// required: true -// type: string -// description: The API id -// - in: path -// name: keyName -// required: true -// type: string -// description: Refresh token -// requestBody: -// content: -// application/json: -// schema: -// "$ref": "#/definitions/NewClientRequest" -// examples: -// client_id: test -// api_id: id -// policy_id: policy +// - in: query +// name: api_id +// required: true +// type: string +// description: The API id +// - in: path +// name: keyName +// required: true +// type: string +// description: Refresh token // responses: // 200: // description: Deleted // schema: -// "$ref": "#/definitions/apiModifyKeySuccess" +// "$ref": "#/responses/apiModifyKeySuccess" func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { apiID := r.URL.Query().Get("api_id") if apiID == "" { @@ -1855,15 +1806,15 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /oauth/clients/{apiID} OAuth listOAuthClients // -// List OAuth clients +// List oAuth clients // //--- // parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID // responses: // 200: // description: Get OAuth client details or a list of OAuth clients @@ -1878,48 +1829,43 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// type: string -// minimum: 1 -// description: The API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// description: API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: Get OAuth client details or a list of OAuth clients // schema: // "$ref": "#/definitions/NewClientRequest" -// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} OAuth deleteOAuthClient +// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} oauth deleteOAuthClient // // Delete oAuth client // //--- // parameters: -// - in: path -// name: apiID -// required: true -// type: string -// minimum: 1 -// description: The API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: OAuth client deleted // schema: // "$ref": "#/responses/apiModifyKeySuccess" -// examples: -// status: "ok" -// action: "deleted" func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -1952,17 +1898,16 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// type: string -// minimum: 1 -// description: The API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID +// - in: path +// name: keyName +// required: true +// type: string +// description: The Client ID // responses: // 200: // description: Get a list of tokens @@ -2178,19 +2123,16 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { // //--- // parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID +// - in: path +// name: apiID +// required: true +// type: string +// description: The API ID // responses: // 200: // description: Invalidate cache // schema: -// $ref: "#/responses/apiStatusMessage" -// examples: -// status: "ok" -// message: "cache invalidated" +// "$ref": "#/responses/apiStatusMessage" func invalidateCacheHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] diff --git a/swagger.go b/swagger.go new file mode 100644 index 00000000000..1cfd95bb8d0 --- /dev/null +++ b/swagger.go @@ -0,0 +1,21 @@ +package main + +import ( + "github.com/TykTechnologies/tyk/apidef" + "github.com/TykTechnologies/tyk/user" +) + +// parameterBodies +// swagger:response parameterBodies +type swaggerParameterBodies struct { + // in: body + APIStatusMessage apiStatusMessage + // in: body + APIModifyKeySuccess apiModifyKeySuccess + // in: body + NewClientRequest NewClientRequest + // in: body + APIDefinition apidef.APIDefinition + // in: body + SessionState user.SessionState +} diff --git a/tracing.go b/tracing.go index 0fb8e9dc612..a0bddf2d2fa 100644 --- a/tracing.go +++ b/tracing.go @@ -29,25 +29,21 @@ func (tr *traceHttpRequest) toRequest() *http.Request { return r } -// Tracing HTTP request -// -// swagger:model +// TraceRequest is for tracing an HTTP request +// swagger:model TraceRequest type traceRequest struct { Request *traceHttpRequest `json:"request"` Spec *apidef.APIDefinition `json:"spec"` } -// Tracing HTTP response -// -// swagger:model +// TraceResponse is for tracing an HTTP response +// swagger:model TraceResponse type traceResponse struct { Message string `json:"message"` Response string `json:"response"` Logs string `json:"logs"` } -// swagger:operation POST /trace trace trace -// // Tracing request // Used to test API definition by sending sample request, // and analysisng output of both response and logs From 23892e7946dd32d7c284b0b166ea3e1fdc96181d Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 18:09:26 +0100 Subject: [PATCH 10/20] add summary to all endpoints --- api.go | 79 ++++++++++++++++++---------------------------------------- 1 file changed, 24 insertions(+), 55 deletions(-) diff --git a/api.go b/api.go index 1c10351b48f..def904334f2 100644 --- a/api.go +++ b/api.go @@ -765,10 +765,8 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // swagger:operation GET /apis APIs listApis // -// List APIs -// Only if used without the Tyk Dashboard -// //--- +// summary: List APIs. // responses: // 200: // description: List of API definitions @@ -779,9 +777,8 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // swagger:operation POST /apis APIs createApi // -// Create API -// //--- +// summary: Create an API // responses: // 200: // description: API created @@ -794,10 +791,8 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // swagger:operation GET /apis/{apiID} APIs getApi // -// Get API -// Only if used without the Tyk Dashboard -// //--- +// summary: Get an API. // parameters: // - in: path // name: apiID @@ -812,10 +807,8 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // swagger:operation DELETE /apis/{apiID} APIs deleteApi // -// Delete API -// Only if used without the Tyk Dashboard -// //--- +// summary: Delete an API. // parameters: // - in: path // name: apiID @@ -870,9 +863,8 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /keys Keys listKeys // -// List all keys -// //--- +// summary: List all keys attached to an API // responses: // 200: // description: List of all API keys @@ -883,9 +875,8 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation POST /keys Keys createKey // -// Create a new key -// //--- +// summary: Create a new API key // responses: // 200: // description: New Key created @@ -896,26 +887,10 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // schema: // "$ref": "#/responses/apiStatusMessage" -// swagger:operation POST /keys Keys addKey -// -// Add an existing Key -// -//--- -// responses: -// 200: -// description: New Key added -// schema: -// "$ref": "#/responses/apiModifyKeySuccess" -// 400: -// description: Malformed data -// schema: -// "$ref": "#/responses/apiStatusMessage" - // swagger:operation PUT /keys/{keyID} Keys updateKey // -// Update a Key -// //--- +// summary: Update an API key // parameters: // - in: path // name: keyID @@ -934,9 +909,8 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /keys/{keyID} Keys getKey // -// Get a key -// //--- +// summary: Retrieve an API key // parameters: // - in: path // name: keyID @@ -951,9 +925,8 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation DELETE /keys/{keyID} Keys deleteKey // -// Delete a key -// //--- +// summary: Delete ann API key // parameters: // - in: path // name: keyID @@ -1310,12 +1283,15 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // Otherwise, it won't block and fn will be called once the reload is // finished. // -// swagger:route GET /reload Reload reload +// swagger:operation GET /reload Reload a gateway instance // -// Reloads a single Tyk Gateway instance -// -// Responses: -// 200: apiStatusMessage +// --- +// summary: Reloads a single Tyk Gateway instance +// responses: +// "200": +// description: All gateways in a cluster were successfully refreshed +// schema: +// "$ref": "#/responses/apiStatusMessage" func resetHandler(fn func()) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var wg sync.WaitGroup @@ -1488,9 +1464,8 @@ func oauthClientStorageID(clientID string) string { // swagger:operation POST /oauth/clients/create OAuth createOAuthClient // -// Create an OAuth client -// //--- +// summary: Create a new OAuth client // parameters: // - in: body // name: client_info @@ -1718,9 +1693,8 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // swagger:operation DELETE /oauth/refresh/{keyName} oauth invalidateOAuthRefresh // -// Invalidate oAuth refresh token -// //--- +// summary: Invalidate oAuth refresh token // parameters: // - in: query // name: api_id @@ -1806,9 +1780,8 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /oauth/clients/{apiID} OAuth listOAuthClients // -// List oAuth clients -// //--- +// summary: List all Oauth clients // parameters: // - in: path // name: apiID @@ -1825,9 +1798,8 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /oauth/clients/{apiID}/{keyName} OAuth getOAuthClient // -// Get OAuth client -// //--- +// summary: Retrieve an oAuth client // parameters: // - in: path // name: apiID @@ -1847,9 +1819,8 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // swagger:operation DELETE /oauth/clients/{apiID}/{keyName} oauth deleteOAuthClient // -// Delete oAuth client -// //--- +// summary: Delete an oAuth client // parameters: // - in: path // name: apiID @@ -1894,9 +1865,8 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation GET /oauth/clients/{apiID}/{keyName}/tokens OAuth getOAuthClientTokens // -// Get OAuth client tokens -// //--- +// summary: Get the tokens of an oAuth client // parameters: // - in: path // name: apiID @@ -2119,9 +2089,8 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { // swagger:operation DELETE /cache/{apiID} Cache invalidateCache // -// Invalidate cache -// //--- +// summary: Invalidate the cache of a given api by it's ID // parameters: // - in: path // name: apiID From 4518cec45d2b80ecc1224e2c095d5b2e867a650e Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 19:59:18 +0100 Subject: [PATCH 11/20] s/swagger:response/swagger:model to make sure the conversion from 2.0 to 3.0 validates without any error --- api.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/api.go b/api.go index def904334f2..2cb68f555ad 100644 --- a/api.go +++ b/api.go @@ -54,7 +54,7 @@ import ( // apiModifyKeySuccess represents when a Key modification was successful // -// swagger:response apiModifyKeySuccess +// swagger:model apiModifyKeySuccess type apiModifyKeySuccess struct { // in:body Key string `json:"key"` @@ -65,7 +65,7 @@ type apiModifyKeySuccess struct { // apiStatusMessage represents an API status message // -// swagger:response apiStatusMessage +// swagger:model apiStatusMessage type apiStatusMessage struct { Status string `json:"status"` // Response details @@ -783,11 +783,11 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // 200: // description: API created // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" // 400: // description: Malformed data // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" // swagger:operation GET /apis/{apiID} APIs getApi // @@ -819,11 +819,11 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // 200: // description: API deleted // schema: -// $ref: "#/responses/apiStatusMessage" +// $ref: "#/definitions/apiStatusMessage" // 400: // description: No API ID specified // schema: -// $ref: "#/responses/apiStatusMessage" +// $ref: "#/definitions/apiStatusMessage" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] @@ -881,11 +881,11 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: New Key created // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" // 400: // description: Malformed data // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" // swagger:operation PUT /keys/{keyID} Keys updateKey // @@ -901,11 +901,11 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: Key updated // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" // 400: // description: No or incorrect Key ID specified // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" // swagger:operation GET /keys/{keyID} Keys getKey // @@ -937,11 +937,11 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: Key deleted // schema: -// $ref: "#/responses/apiStatusMessage" +// $ref: "#/definitions/apiStatusMessage" // 400: // description: No Key ID specified // schema: -// $ref: "#/responses/apiStatusMessage" +// $ref: "#/definitions/apiStatusMessage" func keyHandler(w http.ResponseWriter, r *http.Request) { keyName := mux.Vars(r)["keyName"] apiID := r.URL.Query().Get("api_id") @@ -1261,7 +1261,7 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { // "200": // description: All gateways in a cluster were successfully refreshed // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" func groupResetHandler(w http.ResponseWriter, r *http.Request) { log.WithFields(logrus.Fields{ "prefix": "api", @@ -1291,7 +1291,7 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // "200": // description: All gateways in a cluster were successfully refreshed // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" func resetHandler(fn func()) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var wg sync.WaitGroup @@ -1710,7 +1710,7 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int // 200: // description: Deleted // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { apiID := r.URL.Query().Get("api_id") if apiID == "" { @@ -1836,7 +1836,7 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { // 200: // description: OAuth client deleted // schema: -// "$ref": "#/responses/apiModifyKeySuccess" +// "$ref": "#/definitions/apiModifyKeySuccess" func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -2101,7 +2101,7 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { // 200: // description: Invalidate cache // schema: -// "$ref": "#/responses/apiStatusMessage" +// "$ref": "#/definitions/apiStatusMessage" func invalidateCacheHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] From d268a481d057544cadb77c5c3437d2ae99c53bbc Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 22:11:42 +0100 Subject: [PATCH 12/20] add swagger validation to CI --- .travis.yml | 7 + gateway-swagger.yaml | 1825 ++++++++++++++++++++++++++++++++++++++++++ utils/ci-swagger.sh | 33 + 3 files changed, 1865 insertions(+) create mode 100644 gateway-swagger.yaml create mode 100755 utils/ci-swagger.sh diff --git a/.travis.yml b/.travis.yml index 903084dbb57..293c937b078 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,10 @@ addons: - python3.5 - python3-pip - libluajit-5.1-dev + ### Needed to convert the swagger 2.0 file to openapi 3.0 + ### The swagger docs are actually written as per the 2.0 spec as there is no + ### support for openapi 3.0 in Go - at least for now. + - npm matrix: include: @@ -31,13 +35,16 @@ install: - go install ./... # As of 1.9, ./... no longer includes ./vendor/... - go install ./vendor/{golang.org/x/tools/cmd/goimports,github.com/wadey/gocovmerge,github.com/mattn/goveralls} + - go get github.com/go-swagger/go-swagger/cmd/swagger script: - sudo pip3 install google - sudo pip3 install protobuf + - sudo npm install -g api-spec-converter - go build -tags 'coprocess python' - go build -tags 'coprocess lua' - go build -tags 'coprocess grpc' + - ./utils/ci-swagger.sh - ./utils/ci-test.sh - if [[ $LATEST_GO ]]; then goveralls -coverprofile=<(gocovmerge *.cov); fi - ./utils/ci-benchmark.sh diff --git a/gateway-swagger.yaml b/gateway-swagger.yaml new file mode 100644 index 00000000000..f5b3c3477fd --- /dev/null +++ b/gateway-swagger.yaml @@ -0,0 +1,1825 @@ +openapi: 3.0.0 +info: + description: The code below describes the Tyk Gateway API + title: Tyk Gateway API + version: 2.8.0 +servers: + - url: 'http://localhost/tyk/' + - url: 'https://localhost/tyk/' +paths: + /apis: + get: + responses: + '200': + content: + application/json: + schema: + items: + $ref: '#/components/schemas/APIDefinition' + type: array + description: List of API definitions + tags: + - APIs + operationId: listApis + summary: List APIs. + post: + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiModifyKeySuccess' + description: API created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: Malformed data + tags: + - APIs + operationId: createApi + summary: Create an API + '/apis/{apiID}': + delete: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: API deleted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: No API ID specified + tags: + - APIs + operationId: deleteApi + summary: Delete an API. + get: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/APIDefinition' + description: API definition + tags: + - APIs + operationId: getApi + summary: Get an API. + '/cache/{apiID}': + delete: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: Invalidate cache + tags: + - Cache + operationId: invalidateCache + summary: Invalidate the cache of a given api by it's ID + /keys: + get: + responses: + '200': + content: + application/json: + schema: + items: + type: string + type: array + description: List of all API keys + tags: + - Keys + operationId: listKeys + summary: List all keys attached to an API + post: + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiModifyKeySuccess' + description: New Key created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: Malformed data + tags: + - Keys + operationId: createKey + summary: Create a new API key + '/keys/{keyID}': + delete: + parameters: + - description: The Key ID + in: path + name: keyID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: Key deleted + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: No Key ID specified + tags: + - Keys + operationId: deleteKey + summary: Delete ann API key + get: + parameters: + - description: The Key ID + in: path + name: keyID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SessionState' + description: Key object + tags: + - Keys + operationId: getKey + summary: Retrieve an API key + put: + parameters: + - description: The Key ID + in: path + name: keyID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiModifyKeySuccess' + description: Key updated + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/apiStatusMessage' + description: No or incorrect Key ID specified + tags: + - Keys + operationId: updateKey + summary: Update an API key + /oauth/clients/create: + post: + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NewClientRequest' + description: Client created + tags: + - OAuth + operationId: createOAuthClient + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/NewClientRequest' + required: true + summary: Create a new OAuth client + '/oauth/clients/{apiID}': + get: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + items: + $ref: '#/components/schemas/NewClientRequest' + type: array + description: Get OAuth client details or a list of OAuth clients + tags: + - OAuth + operationId: listOAuthClients + summary: List all Oauth clients + '/oauth/clients/{apiID}/{keyName}': + delete: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + - description: The Client ID + in: path + name: keyName + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiModifyKeySuccess' + description: OAuth client deleted + tags: + - oauth + operationId: deleteOAuthClient + summary: Delete an oAuth client + get: + parameters: + - description: API ID + in: path + name: apiID + required: true + schema: + type: string + - description: The Client ID + in: path + name: keyName + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/NewClientRequest' + description: Get OAuth client details or a list of OAuth clients + tags: + - OAuth + operationId: getOAuthClient + summary: Retrieve an oAuth client + '/oauth/clients/{apiID}/{keyName}/tokens': + get: + parameters: + - description: The API ID + in: path + name: apiID + required: true + schema: + type: string + - description: The Client ID + in: path + name: keyName + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + items: + type: string + type: array + description: Get a list of tokens + tags: + - OAuth + operationId: getOAuthClientTokens + summary: Get the tokens of an oAuth client + '/oauth/refresh/{keyName}': + delete: + parameters: + - description: The API id + in: query + name: api_id + required: true + schema: + type: string + - description: Refresh token + in: path + name: keyName + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/apiModifyKeySuccess' + description: Deleted + tags: + - oauth + operationId: invalidateOAuthRefresh + summary: Invalidate oAuth refresh token + /reload: + get: + responses: + '200': + description: All gateways in a cluster were successfully refreshed + tags: + - Reload + - a + - gateway + operationId: instance + summary: Reloads a single Tyk Gateway instance + /reload/group: + get: + responses: + '200': + description: All gateways in a cluster were successfully refreshed + tags: + - Reload + operationId: reloadGroup + summary: Reloads all the Tyk Gateways in a cluster +components: + responses: + parameterBodies: + content: + application/json: + schema: + $ref: '#/components/schemas/SessionState' + description: parameterBodies + schemas: + APIDefinition: + properties: + tags: + items: + type: string + type: array + x-go-name: Tags + CORS: + properties: + allow_credentials: + type: boolean + x-go-name: AllowCredentials + allowed_headers: + items: + type: string + type: array + x-go-name: AllowedHeaders + allowed_methods: + items: + type: string + type: array + x-go-name: AllowedMethods + allowed_origins: + items: + type: string + type: array + x-go-name: AllowedOrigins + debug: + type: boolean + x-go-name: Debug + enable: + type: boolean + x-go-name: Enable + exposed_headers: + items: + type: string + type: array + x-go-name: ExposedHeaders + max_age: + format: int64 + type: integer + x-go-name: MaxAge + options_passthrough: + type: boolean + x-go-name: OptionsPassthrough + type: object + active: + type: boolean + x-go-name: Active + allowed_ips: + items: + type: string + type: array + x-go-name: AllowedIPs + api_id: + type: string + x-go-name: APIID + auth: + $ref: '#/components/schemas/Auth' + auth_provider: + $ref: '#/components/schemas/AuthProviderMeta' + base_identity_provided_by: + $ref: '#/components/schemas/AuthTypeEnum' + basic_auth: + properties: + cache_ttl: + format: int64 + type: integer + x-go-name: CacheTTL + disable_caching: + type: boolean + x-go-name: DisableCaching + type: object + x-go-name: BasicAuth + blacklisted_ips: + items: + type: string + type: array + x-go-name: BlacklistedIPs + cache_options: + $ref: '#/components/schemas/CacheOptions' + certificates: + items: + type: string + type: array + x-go-name: Certificates + client_certificates: + items: + type: string + type: array + x-go-name: ClientCertificates + config_data: + additionalProperties: + type: object + type: object + x-go-name: ConfigData + custom_middleware: + $ref: '#/components/schemas/MiddlewareSection' + custom_middleware_bundle: + type: string + x-go-name: CustomMiddlewareBundle + definition: + properties: + key: + type: string + x-go-name: Key + location: + type: string + x-go-name: Location + strip_path: + type: boolean + x-go-name: StripPath + type: object + x-go-name: VersionDefinition + disable_quota: + type: boolean + x-go-name: DisableQuota + disable_rate_limit: + type: boolean + x-go-name: DisableRateLimit + do_not_track: + type: boolean + x-go-name: DoNotTrack + domain: + type: string + x-go-name: Domain + dont_set_quota_on_create: + type: boolean + x-go-name: DontSetQuotasOnCreate + enable_batch_request_support: + type: boolean + x-go-name: EnableBatchRequestSupport + enable_context_vars: + type: boolean + x-go-name: EnableContextVars + enable_coprocess_auth: + type: boolean + x-go-name: EnableCoProcessAuth + enable_ip_blacklisting: + type: boolean + x-go-name: EnableIpBlacklisting + enable_ip_whitelisting: + type: boolean + x-go-name: EnableIpWhiteListing + enable_jwt: + type: boolean + x-go-name: EnableJWT + enable_signature_checking: + type: boolean + x-go-name: EnableSignatureChecking + event_handlers: + $ref: '#/components/schemas/EventHandlerMetaConfig' + expire_analytics_after: + format: int64 + type: integer + x-go-name: ExpireAnalyticsAfter + global_rate_limit: + $ref: '#/components/schemas/GlobalRateLimit' + hmac_allowed_algorithms: + items: + type: string + type: array + x-go-name: HmacAllowedAlgorithms + hmac_allowed_clock_skew: + format: double + type: number + x-go-name: HmacAllowedClockSkew + id: + $ref: '#/components/schemas/ObjectId' + internal: + type: boolean + x-go-name: Internal + jwt_client_base_field: + type: string + x-go-name: JWTClientIDBaseField + jwt_expires_at_validation_skew: + format: uint64 + type: integer + x-go-name: JWTExpiresAtValidationSkew + jwt_identity_base_field: + type: string + x-go-name: JWTIdentityBaseField + jwt_issued_at_validation_skew: + format: uint64 + type: integer + x-go-name: JWTIssuedAtValidationSkew + jwt_not_before_validation_skew: + format: uint64 + type: integer + x-go-name: JWTNotBeforeValidationSkew + jwt_policy_field_name: + type: string + x-go-name: JWTPolicyFieldName + jwt_scope_claim_name: + type: string + x-go-name: JWTScopeClaimName + jwt_scope_to_policy_mapping: + additionalProperties: + type: string + type: object + x-go-name: JWTScopeToPolicyMapping + jwt_signing_method: + type: string + x-go-name: JWTSigningMethod + jwt_skip_kid: + type: boolean + x-go-name: JWTSkipKid + jwt_source: + type: string + x-go-name: JWTSource + name: + type: string + x-go-name: Name + notifications: + $ref: '#/components/schemas/NotificationsManager' + oauth_meta: + properties: + allowed_access_types: + items: + $ref: '#/components/schemas/AccessRequestType' + type: array + x-go-name: AllowedAccessTypes + allowed_authorize_types: + items: + $ref: '#/components/schemas/AuthorizeRequestType' + type: array + x-go-name: AllowedAuthorizeTypes + auth_login_redirect: + type: string + x-go-name: AuthorizeLoginRedirect + type: object + x-go-name: Oauth2Meta + openid_options: + $ref: '#/components/schemas/OpenIDOptions' + org_id: + type: string + x-go-name: OrgID + pinned_public_keys: + additionalProperties: + type: string + type: object + x-go-name: PinnedPublicKeys + proxy: + properties: + check_host_against_uptime_tests: + type: boolean + x-go-name: CheckHostAgainstUptimeTests + disable_strip_slash: + type: boolean + x-go-name: DisableStripSlash + enable_load_balancing: + type: boolean + x-go-name: EnableLoadBalancing + listen_path: + type: string + x-go-name: ListenPath + preserve_host_header: + type: boolean + x-go-name: PreserveHostHeader + service_discovery: + $ref: '#/components/schemas/ServiceDiscoveryConfiguration' + strip_listen_path: + type: boolean + x-go-name: StripListenPath + target_list: + items: + type: string + type: array + x-go-name: Targets + target_url: + type: string + x-go-name: TargetURL + transport: + properties: + proxy_url: + type: string + x-go-name: ProxyURL + ssl_ciphers: + items: + type: string + type: array + x-go-name: SSLCipherSuites + ssl_insecure_skip_verify: + type: boolean + x-go-name: SSLInsecureSkipVerify + ssl_min_version: + format: uint16 + type: integer + x-go-name: SSLMinVersion + type: object + x-go-name: Transport + type: object + x-go-name: Proxy + response_processors: + items: + $ref: '#/components/schemas/ResponseProcessor' + type: array + x-go-name: ResponseProcessors + session_lifetime: + format: int64 + type: integer + x-go-name: SessionLifetime + session_provider: + $ref: '#/components/schemas/SessionProviderMeta' + slug: + type: string + x-go-name: Slug + strip_auth_data: + type: boolean + x-go-name: StripAuthData + tag_headers: + items: + type: string + type: array + x-go-name: TagHeaders + upstream_certificates: + additionalProperties: + type: string + type: object + x-go-name: UpstreamCertificates + uptime_tests: + properties: + check_list: + items: + $ref: '#/components/schemas/HostCheckObject' + type: array + x-go-name: CheckList + config: + properties: + expire_utime_after: + format: int64 + type: integer + x-go-name: ExpireUptimeAnalyticsAfter + recheck_wait: + format: int64 + type: integer + x-go-name: RecheckWait + service_discovery: + $ref: '#/components/schemas/ServiceDiscoveryConfiguration' + type: object + x-go-name: Config + type: object + x-go-name: UptimeTests + use_basic_auth: + type: boolean + x-go-name: UseBasicAuth + use_keyless: + type: boolean + x-go-name: UseKeylessAccess + use_mutual_tls_auth: + type: boolean + x-go-name: UseMutualTLSAuth + use_oauth2: + type: boolean + x-go-name: UseOauth2 + use_openid: + type: boolean + x-go-name: UseOpenID + use_standard_auth: + type: boolean + x-go-name: UseStandardAuth + version_data: + properties: + default_version: + type: string + x-go-name: DefaultVersion + not_versioned: + type: boolean + x-go-name: NotVersioned + versions: + additionalProperties: + $ref: '#/components/schemas/VersionInfo' + type: object + x-go-name: Versions + type: object + x-go-name: VersionData + title: >- + APIDefinition represents the configuration for a single proxied API and + it's versions. + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + APILimit: + description: APILimit stores quota and rate limit on ACL level (per API) + properties: + per: + format: double + type: number + x-go-name: Per + quota_max: + format: int64 + type: integer + x-go-name: QuotaMax + quota_remaining: + format: int64 + type: integer + x-go-name: QuotaRemaining + quota_renewal_rate: + format: int64 + type: integer + x-go-name: QuotaRenewalRate + quota_renews: + format: int64 + type: integer + x-go-name: QuotaRenews + rate: + format: double + type: number + x-go-name: Rate + set_by_policy: + type: boolean + x-go-name: SetByPolicy + throttle_interval: + format: double + type: number + x-go-name: ThrottleInterval + throttle_retry_limit: + format: int64 + type: integer + x-go-name: ThrottleRetryLimit + type: object + x-go-package: github.com/TykTechnologies/tyk/user + AccessDefinition: + description: AccessDefinition defines which versions of an API a key has access to + properties: + allowed_urls: + items: + $ref: '#/components/schemas/AccessSpec' + type: array + x-go-name: AllowedURLs + api_id: + type: string + x-go-name: APIID + api_name: + type: string + x-go-name: APIName + limit: + $ref: '#/components/schemas/APILimit' + versions: + items: + type: string + type: array + x-go-name: Versions + type: object + x-go-package: github.com/TykTechnologies/tyk/user + AccessRequestType: + description: AccessRequestType is the type for OAuth param `grant_type` + type: string + x-go-package: github.com/TykTechnologies/tyk/vendor/github.com/lonelycode/osin + AccessSpec: + description: >- + AccessSpecs define what URLS a user has access to an what methods are + enabled + properties: + methods: + items: + type: string + type: array + x-go-name: Methods + url: + type: string + x-go-name: URL + type: object + x-go-package: github.com/TykTechnologies/tyk/user + Auth: + properties: + auth_header_name: + type: string + x-go-name: AuthHeaderName + cookie_name: + type: string + x-go-name: CookieName + param_name: + type: string + x-go-name: ParamName + use_certificate: + type: boolean + x-go-name: UseCertificate + use_cookie: + type: boolean + x-go-name: UseCookie + use_param: + type: boolean + x-go-name: UseParam + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + AuthProviderCode: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + AuthProviderMeta: + properties: + meta: + additionalProperties: + type: object + type: object + x-go-name: Meta + name: + $ref: '#/components/schemas/AuthProviderCode' + storage_engine: + $ref: '#/components/schemas/StorageEngineCode' + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + AuthTypeEnum: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + AuthorizeRequestType: + description: AuthorizeRequestType is the type for OAuth param `response_type` + type: string + x-go-package: github.com/TykTechnologies/tyk/vendor/github.com/lonelycode/osin + CacheOptions: + properties: + cache_all_safe_requests: + type: boolean + x-go-name: CacheAllSafeRequests + cache_control_ttl_header: + type: string + x-go-name: CacheControlTTLHeader + cache_response_codes: + items: + format: int64 + type: integer + type: array + x-go-name: CacheOnlyResponseCodes + cache_timeout: + format: int64 + type: integer + x-go-name: CacheTimeout + enable_cache: + type: boolean + x-go-name: EnableCache + enable_upstream_cache_control: + type: boolean + x-go-name: EnableUpstreamCacheControl + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + CircuitBreakerMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + return_to_service_after: + format: int64 + type: integer + x-go-name: ReturnToServiceAfter + samples: + format: int64 + type: integer + x-go-name: Samples + threshold_percent: + format: double + type: number + x-go-name: ThresholdPercent + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + EndPointMeta: + properties: + method_actions: + additionalProperties: + $ref: '#/components/schemas/EndpointMethodMeta' + type: object + x-go-name: MethodActions + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + EndpointMethodAction: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + EndpointMethodMeta: + properties: + action: + $ref: '#/components/schemas/EndpointMethodAction' + code: + format: int64 + type: integer + x-go-name: Code + data: + type: string + x-go-name: Data + headers: + additionalProperties: + type: string + type: object + x-go-name: Headers + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + EventHandlerMetaConfig: + properties: + events: + x-go-name: Events + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + ExtendedPathsSet: + properties: + black_list: + items: + $ref: '#/components/schemas/EndPointMeta' + type: array + x-go-name: BlackList + cache: + items: + type: string + type: array + x-go-name: Cached + circuit_breakers: + items: + $ref: '#/components/schemas/CircuitBreakerMeta' + type: array + x-go-name: CircuitBreaker + do_not_track_endpoints: + items: + $ref: '#/components/schemas/TrackEndpointMeta' + type: array + x-go-name: DoNotTrackEndpoints + hard_timeouts: + items: + $ref: '#/components/schemas/HardTimeoutMeta' + type: array + x-go-name: HardTimeouts + ignored: + items: + $ref: '#/components/schemas/EndPointMeta' + type: array + x-go-name: Ignored + internal: + items: + $ref: '#/components/schemas/InternalMeta' + type: array + x-go-name: Internal + method_transforms: + items: + $ref: '#/components/schemas/MethodTransformMeta' + type: array + x-go-name: MethodTransforms + size_limits: + items: + $ref: '#/components/schemas/RequestSizeMeta' + type: array + x-go-name: SizeLimit + track_endpoints: + items: + $ref: '#/components/schemas/TrackEndpointMeta' + type: array + x-go-name: TrackEndpoints + transform: + items: + $ref: '#/components/schemas/TemplateMeta' + type: array + x-go-name: Transform + transform_headers: + items: + $ref: '#/components/schemas/HeaderInjectionMeta' + type: array + x-go-name: TransformHeader + transform_jq: + items: + $ref: '#/components/schemas/TransformJQMeta' + type: array + x-go-name: TransformJQ + transform_jq_response: + items: + $ref: '#/components/schemas/TransformJQMeta' + type: array + x-go-name: TransformJQResponse + transform_response: + items: + $ref: '#/components/schemas/TemplateMeta' + type: array + x-go-name: TransformResponse + transform_response_headers: + items: + $ref: '#/components/schemas/HeaderInjectionMeta' + type: array + x-go-name: TransformResponseHeader + url_rewrites: + items: + $ref: '#/components/schemas/URLRewriteMeta' + type: array + x-go-name: URLRewrite + validate_json: + items: + $ref: '#/components/schemas/ValidatePathMeta' + type: array + x-go-name: ValidateJSON + virtual: + items: + $ref: '#/components/schemas/VirtualMeta' + type: array + x-go-name: Virtual + white_list: + items: + $ref: '#/components/schemas/EndPointMeta' + type: array + x-go-name: WhiteList + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + GlobalRateLimit: + properties: + per: + format: double + type: number + x-go-name: Per + rate: + format: double + type: number + x-go-name: Rate + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + HardTimeoutMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + timeout: + format: int64 + type: integer + x-go-name: TimeOut + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + HashType: + type: string + x-go-package: github.com/TykTechnologies/tyk/user + HeaderInjectionMeta: + properties: + act_on: + type: boolean + x-go-name: ActOnResponse + add_headers: + additionalProperties: + type: string + type: object + x-go-name: AddHeaders + delete_headers: + items: + type: string + type: array + x-go-name: DeleteHeaders + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + HostCheckObject: + properties: + body: + type: string + x-go-name: Body + headers: + additionalProperties: + type: string + type: object + x-go-name: Headers + method: + type: string + x-go-name: Method + url: + type: string + x-go-name: CheckURL + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + IdExtractorSource: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + IdExtractorType: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + InternalMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + MethodTransformMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + to_method: + type: string + x-go-name: ToMethod + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + MiddlewareDefinition: + properties: + name: + type: string + x-go-name: Name + path: + type: string + x-go-name: Path + require_session: + type: boolean + x-go-name: RequireSession + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + MiddlewareDriver: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + MiddlewareIdExtractor: + properties: + extract_from: + $ref: '#/components/schemas/IdExtractorSource' + extract_with: + $ref: '#/components/schemas/IdExtractorType' + extractor_config: + additionalProperties: + type: object + type: object + x-go-name: ExtractorConfig + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + MiddlewareSection: + properties: + auth_check: + $ref: '#/components/schemas/MiddlewareDefinition' + driver: + $ref: '#/components/schemas/MiddlewareDriver' + id_extractor: + $ref: '#/components/schemas/MiddlewareIdExtractor' + post: + items: + $ref: '#/components/schemas/MiddlewareDefinition' + type: array + x-go-name: Post + post_key_auth: + items: + $ref: '#/components/schemas/MiddlewareDefinition' + type: array + x-go-name: PostKeyAuth + pre: + items: + $ref: '#/components/schemas/MiddlewareDefinition' + type: array + x-go-name: Pre + response: + items: + $ref: '#/components/schemas/MiddlewareDefinition' + type: array + x-go-name: Response + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + NewClientRequest: + description: >- + NewClientRequest is an outward facing JSON object translated from osin + OAuthClients + properties: + api_id: + type: string + x-go-name: APIID + client_id: + type: string + x-go-name: ClientID + description: + type: string + x-go-name: Description + meta_data: + type: object + x-go-name: MetaData + policy_id: + type: string + x-go-name: PolicyID + redirect_uri: + type: string + x-go-name: ClientRedirectURI + secret: + type: string + x-go-name: ClientSecret + type: object + x-go-package: github.com/TykTechnologies/tyk + NotificationsManager: + description: 'TODO: Make this more generic' + properties: + oauth_on_keychange_url: + type: string + x-go-name: OAuthKeyChangeURL + shared_secret: + type: string + x-go-name: SharedSecret + title: >- + NotificationsManager handles sending notifications to OAuth endpoints to + notify the provider of key changes. + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + OIDProviderConfig: + properties: + client_ids: + additionalProperties: + type: string + type: object + x-go-name: ClientIDs + issuer: + type: string + x-go-name: Issuer + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + ObjectId: + description: 'http://www.mongodb.org/display/DOCS/Object+IDs' + title: >- + ObjectId is a unique ID identifying a BSON value. It must be exactly 12 + bytes + + long. MongoDB objects by default have such a property set in their "_id" + + property. + type: string + x-go-package: github.com/TykTechnologies/tyk/vendor/gopkg.in/mgo.v2/bson + OpenIDOptions: + properties: + providers: + items: + $ref: '#/components/schemas/OIDProviderConfig' + type: array + x-go-name: Providers + segregate_by_client: + type: boolean + x-go-name: SegregateByClient + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + Regexp: + description: Regexp is a wrapper around regexp.Regexp but with caching + properties: + FromCache: + type: boolean + type: object + x-go-package: github.com/TykTechnologies/tyk/regexp + RequestInputType: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + RequestSizeMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + size_limit: + format: int64 + type: integer + x-go-name: SizeLimit + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + ResponseProcessor: + properties: + name: + type: string + x-go-name: Name + options: + type: object + x-go-name: Options + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + RoutingTrigger: + properties: + 'on': + $ref: '#/components/schemas/RoutingTriggerOnType' + options: + $ref: '#/components/schemas/RoutingTriggerOptions' + rewrite_to: + type: string + x-go-name: RewriteTo + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + RoutingTriggerOnType: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + RoutingTriggerOptions: + properties: + header_matches: + additionalProperties: + $ref: '#/components/schemas/StringRegexMap' + type: object + x-go-name: HeaderMatches + path_part_matches: + additionalProperties: + $ref: '#/components/schemas/StringRegexMap' + type: object + x-go-name: PathPartMatches + payload_matches: + $ref: '#/components/schemas/StringRegexMap' + query_val_matches: + additionalProperties: + $ref: '#/components/schemas/StringRegexMap' + type: object + x-go-name: QueryValMatches + request_context_matches: + additionalProperties: + $ref: '#/components/schemas/StringRegexMap' + type: object + x-go-name: RequestContextMatches + session_meta_matches: + additionalProperties: + $ref: '#/components/schemas/StringRegexMap' + type: object + x-go-name: SessionMetaMatches + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + ServiceDiscoveryConfiguration: + properties: + cache_timeout: + format: int64 + type: integer + x-go-name: CacheTimeout + data_path: + type: string + x-go-name: DataPath + endpoint_returns_list: + type: boolean + x-go-name: EndpointReturnsList + parent_data_path: + type: string + x-go-name: ParentDataPath + port_data_path: + type: string + x-go-name: PortDataPath + query_endpoint: + type: string + x-go-name: QueryEndpoint + target_path: + type: string + x-go-name: TargetPath + use_discovery_service: + type: boolean + x-go-name: UseDiscoveryService + use_nested_query: + type: boolean + x-go-name: UseNestedQuery + use_target_list: + type: boolean + x-go-name: UseTargetList + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + SessionProviderCode: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + SessionProviderMeta: + properties: + meta: + additionalProperties: + type: object + type: object + x-go-name: Meta + name: + $ref: '#/components/schemas/SessionProviderCode' + storage_engine: + $ref: '#/components/schemas/StorageEngineCode' + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + SessionState: + description: >- + There's a data structure that's based on this and it's used for Protocol + Buffer support, make sure to update + "coprocess/proto/coprocess_session_state.proto" and generate the + bindings using: cd coprocess/proto && ./update_bindings.sh + properties: + tags: + items: + type: string + type: array + x-go-name: Tags + access_rights: + additionalProperties: + $ref: '#/components/schemas/AccessDefinition' + type: object + x-go-name: AccessRights + alias: + type: string + x-go-name: Alias + allowance: + format: double + type: number + x-go-name: Allowance + apply_policies: + items: + type: string + type: array + x-go-name: ApplyPolicies + apply_policy_id: + type: string + x-go-name: ApplyPolicyID + basic_auth_data: + properties: + hash_type: + $ref: '#/components/schemas/HashType' + password: + type: string + x-go-name: Password + type: object + x-go-name: BasicAuthData + certificate: + type: string + x-go-name: Certificate + data_expires: + format: int64 + type: integer + x-go-name: DataExpires + enable_detail_recording: + type: boolean + x-go-name: EnableDetailedRecording + expires: + format: int64 + type: integer + x-go-name: Expires + hmac_enabled: + type: boolean + x-go-name: HMACEnabled + hmac_string: + type: string + x-go-name: HmacSecret + id_extractor_deadline: + format: int64 + type: integer + x-go-name: IdExtractorDeadline + is_inactive: + type: boolean + x-go-name: IsInactive + jwt_data: + properties: + secret: + type: string + x-go-name: Secret + type: object + x-go-name: JWTData + last_check: + format: int64 + type: integer + x-go-name: LastCheck + last_updated: + type: string + x-go-name: LastUpdated + meta_data: + additionalProperties: + type: object + type: object + x-go-name: MetaData + monitor: + properties: + trigger_limits: + items: + format: double + type: number + type: array + x-go-name: TriggerLimits + type: object + x-go-name: Monitor + oauth_client_id: + type: string + x-go-name: OauthClientID + oauth_keys: + additionalProperties: + type: string + type: object + x-go-name: OauthKeys + org_id: + type: string + x-go-name: OrgID + per: + format: double + type: number + x-go-name: Per + quota_max: + format: int64 + type: integer + x-go-name: QuotaMax + quota_remaining: + format: int64 + type: integer + x-go-name: QuotaRemaining + quota_renewal_rate: + format: int64 + type: integer + x-go-name: QuotaRenewalRate + quota_renews: + format: int64 + type: integer + x-go-name: QuotaRenews + rate: + format: double + type: number + x-go-name: Rate + session_lifetime: + format: int64 + type: integer + x-go-name: SessionLifetime + throttle_interval: + format: double + type: number + x-go-name: ThrottleInterval + throttle_retry_limit: + format: int64 + type: integer + x-go-name: ThrottleRetryLimit + title: >- + SessionState objects represent a current API session, mainly used for + rate limiting. + type: object + x-go-package: github.com/TykTechnologies/tyk/user + StorageEngineCode: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + StringRegexMap: + properties: + match_rx: + type: string + x-go-name: MatchPattern + reverse: + type: boolean + x-go-name: Reverse + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + TemplateData: + properties: + enable_session: + type: boolean + x-go-name: EnableSession + input_type: + $ref: '#/components/schemas/RequestInputType' + template_mode: + $ref: '#/components/schemas/TemplateMode' + template_source: + type: string + x-go-name: TemplateSource + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + TemplateMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + template_data: + $ref: '#/components/schemas/TemplateData' + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + TemplateMode: + type: string + x-go-package: github.com/TykTechnologies/tyk/apidef + TrackEndpointMeta: + properties: + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + TransformJQMeta: + properties: + filter: + type: string + x-go-name: Filter + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + URLRewriteMeta: + properties: + MatchRegexp: + $ref: '#/components/schemas/Regexp' + match_pattern: + type: string + x-go-name: MatchPattern + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + rewrite_to: + type: string + x-go-name: RewriteTo + triggers: + items: + $ref: '#/components/schemas/RoutingTrigger' + type: array + x-go-name: Triggers + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + ValidatePathMeta: + properties: + error_response_code: + description: >- + Allows override of default 422 Unprocessible Entity response code + for validation errors. + format: int64 + type: integer + x-go-name: ErrorResponseCode + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + schema: + additionalProperties: + type: object + type: object + x-go-name: Schema + schema_b64: + type: string + x-go-name: SchemaB64 + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + VersionInfo: + properties: + paths: + properties: + black_list: + items: + type: string + type: array + x-go-name: BlackList + ignored: + items: + type: string + type: array + x-go-name: Ignored + white_list: + items: + type: string + type: array + x-go-name: WhiteList + type: object + x-go-name: Paths + expires: + type: string + x-go-name: Expires + extended_paths: + $ref: '#/components/schemas/ExtendedPathsSet' + global_headers: + additionalProperties: + type: string + type: object + x-go-name: GlobalHeaders + global_headers_remove: + items: + type: string + type: array + x-go-name: GlobalHeadersRemove + global_size_limit: + format: int64 + type: integer + x-go-name: GlobalSizeLimit + name: + type: string + x-go-name: Name + override_target: + type: string + x-go-name: OverrideTarget + use_extended_paths: + type: boolean + x-go-name: UseExtendedPaths + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + VirtualMeta: + properties: + function_source_type: + type: string + x-go-name: FunctionSourceType + function_source_uri: + type: string + x-go-name: FunctionSourceURI + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + proxy_on_error: + type: boolean + x-go-name: ProxyOnError + response_function_name: + type: string + x-go-name: ResponseFunctionName + use_session: + type: boolean + x-go-name: UseSession + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef + apiModifyKeySuccess: + description: apiModifyKeySuccess represents when a Key modification was successful + properties: + action: + type: string + x-go-name: Action + key: + description: 'in:body' + type: string + x-go-name: Key + key_hash: + type: string + x-go-name: KeyHash + status: + type: string + x-go-name: Status + type: object + x-go-package: github.com/TykTechnologies/tyk + apiStatusMessage: + description: apiStatusMessage represents an API status message + properties: + message: + description: Response details + type: string + x-go-name: Message + status: + type: string + x-go-name: Status + type: object + x-go-package: github.com/TykTechnologies/tyk + securitySchemes: + api_key: + in: header + name: X-Tyk-Authorization + type: apiKey +security: + - api_key: [] + diff --git a/utils/ci-swagger.sh b/utils/ci-swagger.sh new file mode 100755 index 00000000000..4fd17b1c97f --- /dev/null +++ b/utils/ci-swagger.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +swagger2fileName="swagger2.yaml" +openAPIspecfileName="gateway-swagger.yaml" + +fatal() { + echo "$@" >&2 + exit 1 +} + +swagger generate spec -o "$swagger2fileName" + +if [ $? -ne 0 ]; then + fatal "could not generate swagger2.0 spec to the specified path, $swagger2fileName" +fi + +swagger validate "$swagger2fileName" + +if [ $? -ne 0 ]; then + fatal "swagger spec is invalid... swagger spec is located at $swagger2fileName" +fi + +api-spec-converter --from=swagger_2 --to=openapi_3 --syntax=yaml "$swagger2fileName" > "$openAPIspecfileName" + +if [ $? -ne 0 ]; then + fatal "could not convert swagger2.0 spec to opeenapi 3.0" +fi + +## clean up +rm "$swagger2fileName" + +## Ideally, CI should push $openAPIspecfileName to GitHub +## but for now, it can be committed by users and pushed alonside their changes. From 4e8af5cab4709072419bdeb36e1092d6530edcaf Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 22:13:19 +0100 Subject: [PATCH 13/20] HTTPS before HTTP --- api.go | 2 +- gateway-swagger.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 2cb68f555ad..5ef23b6f6bb 100644 --- a/api.go +++ b/api.go @@ -3,7 +3,7 @@ // The code below describes the Tyk Gateway API // Version: 2.8.0 // -// Schemes: http, https +// Schemes: https, http // Host: localhost // BasePath: /tyk/ // diff --git a/gateway-swagger.yaml b/gateway-swagger.yaml index f5b3c3477fd..c97b570e75b 100644 --- a/gateway-swagger.yaml +++ b/gateway-swagger.yaml @@ -4,8 +4,8 @@ info: title: Tyk Gateway API version: 2.8.0 servers: - - url: 'http://localhost/tyk/' - url: 'https://localhost/tyk/' + - url: 'http://localhost/tyk/' paths: /apis: get: From 1164b52e1772e8b1d40d26cabf93c9d3a9535f75 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Tue, 19 Feb 2019 22:28:15 +0100 Subject: [PATCH 14/20] upgrade npm to prevent ssl errors use latest nodejs to try to solve CERT_UNTRUSTED errors --- .travis.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 293c937b078..35ad5dd4161 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,6 @@ addons: - python3.5 - python3-pip - libluajit-5.1-dev - ### Needed to convert the swagger 2.0 file to openapi 3.0 - ### The swagger docs are actually written as per the 2.0 spec as there is no - ### support for openapi 3.0 in Go - at least for now. - - npm matrix: include: @@ -40,7 +36,13 @@ install: script: - sudo pip3 install google - sudo pip3 install protobuf - - sudo npm install -g api-spec-converter + ### Needed to convert the swagger 2.0 file to openapi 3.0 + ### The swagger docs are actually written as per the 2.0 spec as there is no + ### support for openapi 3.0 in Go - at least for now. + ### https://github.com/nodesource/distributions/blob/master/README.md#debinstall + - curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - + - sudo -E apt-get -yq --no-install-suggests --no-install-recommends $(travis_apt_get_options) install nodejs + - sudo npm install -g api-spec-converter --unsafe-perm=true --allow-root - go build -tags 'coprocess python' - go build -tags 'coprocess lua' - go build -tags 'coprocess grpc' From a2e030e80fe3bdb5528aea7f46fb4f585308f282 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Wed, 20 Feb 2019 14:48:44 +0100 Subject: [PATCH 15/20] s/ann/an --- api.go | 2 +- gateway-swagger.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 5ef23b6f6bb..97ba250531a 100644 --- a/api.go +++ b/api.go @@ -926,7 +926,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // swagger:operation DELETE /keys/{keyID} Keys deleteKey // //--- -// summary: Delete ann API key +// summary: Delete an API key // parameters: // - in: path // name: keyID diff --git a/gateway-swagger.yaml b/gateway-swagger.yaml index c97b570e75b..a457130f39b 100644 --- a/gateway-swagger.yaml +++ b/gateway-swagger.yaml @@ -163,7 +163,7 @@ paths: tags: - Keys operationId: deleteKey - summary: Delete ann API key + summary: Delete an API key get: parameters: - description: The Key ID From a267a9b9f52e3aab6a070af330b323a8b867e5e1 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Mon, 15 Apr 2019 12:09:36 +0100 Subject: [PATCH 16/20] update request body --- api.go | 28 +++++++++--- gateway-swagger.yaml | 103 +++++++++++++++++++++++++++++++++++++++---- oauth_manager.go | 1 + swagger.go | 4 ++ 4 files changed, 120 insertions(+), 16 deletions(-) diff --git a/api.go b/api.go index 97ba250531a..85c3b317cc4 100644 --- a/api.go +++ b/api.go @@ -479,6 +479,7 @@ func handleGetDetail(sessionKey, apiID string, byHash bool) (interface{}, int) { } // apiAllKeys represents a list of keys in the memory store +// swagger:model type apiAllKeys struct { APIKeys []string `json:"keys"` } @@ -779,6 +780,12 @@ func handleDeleteAPI(apiID string) (interface{}, int) { // //--- // summary: Create an API +// parameters: +// - in: body +// name: client_info +// required: true +// schema: +// "$ref": "#/definitions/APIDefinition" // responses: // 200: // description: API created @@ -869,14 +876,17 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // 200: // description: List of all API keys // schema: -// type: array -// items: -// type: string +// "$ref": "#/definitions/apiAllKeys" // swagger:operation POST /keys Keys createKey // //--- // summary: Create a new API key +// parameters: +// - in: body +// required: true +// schema: +// "$ref": "#/definitions/SessionState" // responses: // 200: // description: New Key created @@ -892,6 +902,11 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { //--- // summary: Update an API key // parameters: +// - in: body +// required: true +// schema: +// "$ref": "#/definitions/SessionState" +// parameters: // - in: path // name: keyID // required: true @@ -1254,7 +1269,7 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { return statusObj, http.StatusOK } -// swagger:operation GET /reload/group Reload reloadGroup +// swagger:operation GET /reload/group Reload groupResetHandler // --- // summary: Reloads all the Tyk Gateways in a cluster // responses: @@ -1283,7 +1298,7 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // Otherwise, it won't block and fn will be called once the reload is // finished. // -// swagger:operation GET /reload Reload a gateway instance +// swagger:operation GET /reload Reload resetHandler // // --- // summary: Reloads a single Tyk Gateway instance @@ -1468,7 +1483,6 @@ func oauthClientStorageID(clientID string) string { // summary: Create a new OAuth client // parameters: // - in: body -// name: client_info // required: true // schema: // "$ref": "#/definitions/NewClientRequest" @@ -1884,7 +1898,7 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { // schema: // type: array // items: -// type: string +// "$ref": "#/definitions/OAuthClientToken" func oAuthClientTokensHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] diff --git a/gateway-swagger.yaml b/gateway-swagger.yaml index a457130f39b..23232b9cf2a 100644 --- a/gateway-swagger.yaml +++ b/gateway-swagger.yaml @@ -39,6 +39,12 @@ paths: tags: - APIs operationId: createApi + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/APIDefinition' + required: true summary: Create an API '/apis/{apiID}': delete: @@ -112,9 +118,7 @@ paths: content: application/json: schema: - items: - type: string - type: array + $ref: '#/components/schemas/apiAllKeys' description: List of all API keys tags: - Keys @@ -137,6 +141,12 @@ paths: tags: - Keys operationId: createKey + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SessionState' + required: true summary: Create a new API key '/keys/{keyID}': delete: @@ -321,7 +331,7 @@ paths: application/json: schema: items: - type: string + $ref: '#/components/schemas/OAuthClientToken' type: array description: Get a list of tokens tags: @@ -361,9 +371,7 @@ paths: description: All gateways in a cluster were successfully refreshed tags: - Reload - - a - - gateway - operationId: instance + operationId: resetHandler summary: Reloads a single Tyk Gateway instance /reload/group: get: @@ -372,7 +380,7 @@ paths: description: All gateways in a cluster were successfully refreshed tags: - Reload - operationId: reloadGroup + operationId: groupResetHandler summary: Reloads all the Tyk Gateways in a cluster components: responses: @@ -380,7 +388,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/SessionState' + $ref: '#/components/schemas/OAuthClientToken' description: parameterBodies schemas: APIDefinition: @@ -448,6 +456,12 @@ components: $ref: '#/components/schemas/AuthTypeEnum' basic_auth: properties: + body_password_regexp: + type: string + x-go-name: BodyPasswordRegexp + body_user_regexp: + type: string + x-go-name: BodyUserRegexp cache_ttl: format: int64 type: integer @@ -455,6 +469,9 @@ components: disable_caching: type: boolean x-go-name: DisableCaching + extract_from_body: + type: boolean + x-go-name: ExtractFromBody type: object x-go-name: BasicAuth blacklisted_ips: @@ -857,6 +874,8 @@ components: param_name: type: string x-go-name: ParamName + signature: + $ref: '#/components/schemas/SignatureConfig' use_certificate: type: boolean x-go-name: UseCertificate @@ -866,6 +885,9 @@ components: use_param: type: boolean x-go-name: UseParam + validate_signature: + type: boolean + x-go-name: ValidateSignature type: object x-go-package: github.com/TykTechnologies/tyk/apidef AuthProviderCode: @@ -891,6 +913,19 @@ components: description: AuthorizeRequestType is the type for OAuth param `response_type` type: string x-go-package: github.com/TykTechnologies/tyk/vendor/github.com/lonelycode/osin + CacheMeta: + properties: + cache_key_regex: + type: string + x-go-name: CacheKeyRegex + method: + type: string + x-go-name: Method + path: + type: string + x-go-name: Path + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef CacheOptions: properties: cache_all_safe_requests: @@ -980,6 +1015,11 @@ components: x-go-package: github.com/TykTechnologies/tyk/apidef ExtendedPathsSet: properties: + advance_cache_config: + items: + $ref: '#/components/schemas/CacheMeta' + type: array + x-go-name: AdvanceCacheConfig black_list: items: $ref: '#/components/schemas/EndPointMeta' @@ -1282,6 +1322,17 @@ components: notify the provider of key changes. type: object x-go-package: github.com/TykTechnologies/tyk/apidef + OAuthClientToken: + properties: + code: + type: string + x-go-name: Token + expires: + format: int64 + type: integer + x-go-name: Expires + type: object + x-go-package: github.com/TykTechnologies/tyk OIDProviderConfig: properties: client_ids: @@ -1596,6 +1647,30 @@ components: rate limiting. type: object x-go-package: github.com/TykTechnologies/tyk/user + SignatureConfig: + properties: + algorithm: + type: string + x-go-name: Algorithm + allowed_clock_skew: + format: int64 + type: integer + x-go-name: AllowedClockSkew + error_code: + format: int64 + type: integer + x-go-name: ErrorCode + error_message: + type: string + x-go-name: ErrorMessage + header: + type: string + x-go-name: Header + secret: + type: string + x-go-name: Secret + type: object + x-go-package: github.com/TykTechnologies/tyk/apidef StorageEngineCode: type: string x-go-package: github.com/TykTechnologies/tyk/apidef @@ -1785,6 +1860,16 @@ components: x-go-name: UseSession type: object x-go-package: github.com/TykTechnologies/tyk/apidef + apiAllKeys: + description: apiAllKeys represents a list of keys in the memory store + properties: + keys: + items: + type: string + type: array + x-go-name: APIKeys + type: object + x-go-package: github.com/TykTechnologies/tyk apiModifyKeySuccess: description: apiModifyKeySuccess represents when a Key modification was successful properties: diff --git a/oauth_manager.go b/oauth_manager.go index 2453c3cd87c..7d5f8ae29b3 100644 --- a/oauth_manager.go +++ b/oauth_manager.go @@ -372,6 +372,7 @@ const ( prefixClientTokens = "oauth-client-tokens." ) +// swagger:model type OAuthClientToken struct { Token string `json:"code"` Expires int64 `json:"expires"` diff --git a/swagger.go b/swagger.go index 1cfd95bb8d0..844f0db9cbe 100644 --- a/swagger.go +++ b/swagger.go @@ -18,4 +18,8 @@ type swaggerParameterBodies struct { APIDefinition apidef.APIDefinition // in: body SessionState user.SessionState + // in:body + APIAllKeys apiAllKeys + // in: body + OAuthClientToken OAuthClientToken } From 9162a244f1a9b1160530f95f82704e9ba1d6de1e Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Wed, 17 Apr 2019 11:56:03 +0100 Subject: [PATCH 17/20] add name to body parameters --- api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api.go b/api.go index 85c3b317cc4..e4ecbfa501e 100644 --- a/api.go +++ b/api.go @@ -884,6 +884,7 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { // summary: Create a new API key // parameters: // - in: body +// name: createKey // required: true // schema: // "$ref": "#/definitions/SessionState" @@ -1484,6 +1485,7 @@ func oauthClientStorageID(clientID string) string { // parameters: // - in: body // required: true +// name: oauth_client // schema: // "$ref": "#/definitions/NewClientRequest" // responses: From 9367025561724ea6ce572edf948457541e839036 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Thu, 25 Apr 2019 12:31:15 +0100 Subject: [PATCH 18/20] remove swagger operation --- api.go | 305 --------------------------------------------------------- 1 file changed, 305 deletions(-) diff --git a/api.go b/api.go index e4ecbfa501e..3051287c12d 100644 --- a/api.go +++ b/api.go @@ -764,73 +764,6 @@ func handleDeleteAPI(apiID string) (interface{}, int) { return response, http.StatusOK } -// swagger:operation GET /apis APIs listApis -// -//--- -// summary: List APIs. -// responses: -// 200: -// description: List of API definitions -// schema: -// type: array -// items: -// "$ref": "#/definitions/APIDefinition" - -// swagger:operation POST /apis APIs createApi -// -//--- -// summary: Create an API -// parameters: -// - in: body -// name: client_info -// required: true -// schema: -// "$ref": "#/definitions/APIDefinition" -// responses: -// 200: -// description: API created -// schema: -// "$ref": "#/definitions/apiModifyKeySuccess" -// 400: -// description: Malformed data -// schema: -// "$ref": "#/definitions/apiStatusMessage" - -// swagger:operation GET /apis/{apiID} APIs getApi -// -//--- -// summary: Get an API. -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// responses: -// 200: -// description: API definition -// schema: -// $ref: "#/definitions/APIDefinition" - -// swagger:operation DELETE /apis/{apiID} APIs deleteApi -// -//--- -// summary: Delete an API. -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// responses: -// 200: -// description: API deleted -// schema: -// $ref: "#/definitions/apiStatusMessage" -// 400: -// description: No API ID specified -// schema: -// $ref: "#/definitions/apiStatusMessage" func apiHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] @@ -868,96 +801,6 @@ func apiHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } -// swagger:operation GET /keys Keys listKeys -// -//--- -// summary: List all keys attached to an API -// responses: -// 200: -// description: List of all API keys -// schema: -// "$ref": "#/definitions/apiAllKeys" - -// swagger:operation POST /keys Keys createKey -// -//--- -// summary: Create a new API key -// parameters: -// - in: body -// name: createKey -// required: true -// schema: -// "$ref": "#/definitions/SessionState" -// responses: -// 200: -// description: New Key created -// schema: -// "$ref": "#/definitions/apiModifyKeySuccess" -// 400: -// description: Malformed data -// schema: -// "$ref": "#/definitions/apiStatusMessage" - -// swagger:operation PUT /keys/{keyID} Keys updateKey -// -//--- -// summary: Update an API key -// parameters: -// - in: body -// required: true -// schema: -// "$ref": "#/definitions/SessionState" -// parameters: -// - in: path -// name: keyID -// required: true -// type: string -// description: The Key ID -// responses: -// 200: -// description: Key updated -// schema: -// "$ref": "#/definitions/apiModifyKeySuccess" -// 400: -// description: No or incorrect Key ID specified -// schema: -// "$ref": "#/definitions/apiStatusMessage" - -// swagger:operation GET /keys/{keyID} Keys getKey -// -//--- -// summary: Retrieve an API key -// parameters: -// - in: path -// name: keyID -// required: true -// type: string -// description: The Key ID -// responses: -// 200: -// description: Key object -// schema: -// $ref: "#/definitions/SessionState" - -// swagger:operation DELETE /keys/{keyID} Keys deleteKey -// -//--- -// summary: Delete an API key -// parameters: -// - in: path -// name: keyID -// required: true -// type: string -// description: The Key ID -// responses: -// 200: -// description: Key deleted -// schema: -// $ref: "#/definitions/apiStatusMessage" -// 400: -// description: No Key ID specified -// schema: -// $ref: "#/definitions/apiStatusMessage" func keyHandler(w http.ResponseWriter, r *http.Request) { keyName := mux.Vars(r)["keyName"] apiID := r.URL.Query().Get("api_id") @@ -1270,14 +1113,6 @@ func handleDeleteOrgKey(orgID string) (interface{}, int) { return statusObj, http.StatusOK } -// swagger:operation GET /reload/group Reload groupResetHandler -// --- -// summary: Reloads all the Tyk Gateways in a cluster -// responses: -// "200": -// description: All gateways in a cluster were successfully refreshed -// schema: -// "$ref": "#/definitions/apiStatusMessage" func groupResetHandler(w http.ResponseWriter, r *http.Request) { log.WithFields(logrus.Fields{ "prefix": "api", @@ -1299,15 +1134,6 @@ func groupResetHandler(w http.ResponseWriter, r *http.Request) { // Otherwise, it won't block and fn will be called once the reload is // finished. // -// swagger:operation GET /reload Reload resetHandler -// -// --- -// summary: Reloads a single Tyk Gateway instance -// responses: -// "200": -// description: All gateways in a cluster were successfully refreshed -// schema: -// "$ref": "#/definitions/apiStatusMessage" func resetHandler(fn func()) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { var wg sync.WaitGroup @@ -1478,21 +1304,6 @@ func oauthClientStorageID(clientID string) string { return prefixClient + clientID } -// swagger:operation POST /oauth/clients/create OAuth createOAuthClient -// -//--- -// summary: Create a new OAuth client -// parameters: -// - in: body -// required: true -// name: oauth_client -// schema: -// "$ref": "#/definitions/NewClientRequest" -// responses: -// 200: -// description: Client created -// schema: -// "$ref": "#/definitions/NewClientRequest" func createOauthClient(w http.ResponseWriter, r *http.Request) { var newOauthClient NewClientRequest if err := json.NewDecoder(r.Body).Decode(&newOauthClient); err != nil { @@ -1707,26 +1518,6 @@ func updateOauthClient(keyName, apiID string, r *http.Request) (interface{}, int return replyData, http.StatusOK } -// swagger:operation DELETE /oauth/refresh/{keyName} oauth invalidateOAuthRefresh -// -//--- -// summary: Invalidate oAuth refresh token -// parameters: -// - in: query -// name: api_id -// required: true -// type: string -// description: The API id -// - in: path -// name: keyName -// required: true -// type: string -// description: Refresh token -// responses: -// 200: -// description: Deleted -// schema: -// "$ref": "#/definitions/apiModifyKeySuccess" func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { apiID := r.URL.Query().Get("api_id") if apiID == "" { @@ -1794,65 +1585,6 @@ func invalidateOauthRefresh(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, success) } -// swagger:operation GET /oauth/clients/{apiID} OAuth listOAuthClients -// -//--- -// summary: List all Oauth clients -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// responses: -// 200: -// description: Get OAuth client details or a list of OAuth clients -// schema: -// type: array -// items: -// "$ref": "#/definitions/NewClientRequest" - -// swagger:operation GET /oauth/clients/{apiID}/{keyName} OAuth getOAuthClient -// -//--- -// summary: Retrieve an oAuth client -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID -// responses: -// 200: -// description: Get OAuth client details or a list of OAuth clients -// schema: -// "$ref": "#/definitions/NewClientRequest" - -// swagger:operation DELETE /oauth/clients/{apiID}/{keyName} oauth deleteOAuthClient -// -//--- -// summary: Delete an oAuth client -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID -// responses: -// 200: -// description: OAuth client deleted -// schema: -// "$ref": "#/definitions/apiModifyKeySuccess" func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -1879,28 +1611,6 @@ func oAuthClientHandler(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, code, obj) } -// swagger:operation GET /oauth/clients/{apiID}/{keyName}/tokens OAuth getOAuthClientTokens -// -//--- -// summary: Get the tokens of an oAuth client -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// - in: path -// name: keyName -// required: true -// type: string -// description: The Client ID -// responses: -// 200: -// description: Get a list of tokens -// schema: -// type: array -// items: -// "$ref": "#/definitions/OAuthClientToken" func oAuthClientTokensHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] keyName := mux.Vars(r)["keyName"] @@ -2103,21 +1813,6 @@ func userRatesCheck(w http.ResponseWriter, r *http.Request) { doJSONWrite(w, http.StatusOK, returnSession) } -// swagger:operation DELETE /cache/{apiID} Cache invalidateCache -// -//--- -// summary: Invalidate the cache of a given api by it's ID -// parameters: -// - in: path -// name: apiID -// required: true -// type: string -// description: The API ID -// responses: -// 200: -// description: Invalidate cache -// schema: -// "$ref": "#/definitions/apiStatusMessage" func invalidateCacheHandler(w http.ResponseWriter, r *http.Request) { apiID := mux.Vars(r)["apiID"] From 552553d9a9c661c5b61ac06a615262b41e7a8e12 Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Thu, 25 Apr 2019 12:52:15 +0100 Subject: [PATCH 19/20] update swagger docs --- gateway-swagger.yaml | 377 +------------------------------------------ 1 file changed, 1 insertion(+), 376 deletions(-) diff --git a/gateway-swagger.yaml b/gateway-swagger.yaml index 23232b9cf2a..9a64c7b79ed 100644 --- a/gateway-swagger.yaml +++ b/gateway-swagger.yaml @@ -6,382 +6,7 @@ info: servers: - url: 'https://localhost/tyk/' - url: 'http://localhost/tyk/' -paths: - /apis: - get: - responses: - '200': - content: - application/json: - schema: - items: - $ref: '#/components/schemas/APIDefinition' - type: array - description: List of API definitions - tags: - - APIs - operationId: listApis - summary: List APIs. - post: - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiModifyKeySuccess' - description: API created - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: Malformed data - tags: - - APIs - operationId: createApi - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/APIDefinition' - required: true - summary: Create an API - '/apis/{apiID}': - delete: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: API deleted - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: No API ID specified - tags: - - APIs - operationId: deleteApi - summary: Delete an API. - get: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/APIDefinition' - description: API definition - tags: - - APIs - operationId: getApi - summary: Get an API. - '/cache/{apiID}': - delete: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: Invalidate cache - tags: - - Cache - operationId: invalidateCache - summary: Invalidate the cache of a given api by it's ID - /keys: - get: - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiAllKeys' - description: List of all API keys - tags: - - Keys - operationId: listKeys - summary: List all keys attached to an API - post: - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiModifyKeySuccess' - description: New Key created - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: Malformed data - tags: - - Keys - operationId: createKey - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/SessionState' - required: true - summary: Create a new API key - '/keys/{keyID}': - delete: - parameters: - - description: The Key ID - in: path - name: keyID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: Key deleted - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: No Key ID specified - tags: - - Keys - operationId: deleteKey - summary: Delete an API key - get: - parameters: - - description: The Key ID - in: path - name: keyID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/SessionState' - description: Key object - tags: - - Keys - operationId: getKey - summary: Retrieve an API key - put: - parameters: - - description: The Key ID - in: path - name: keyID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiModifyKeySuccess' - description: Key updated - '400': - content: - application/json: - schema: - $ref: '#/components/schemas/apiStatusMessage' - description: No or incorrect Key ID specified - tags: - - Keys - operationId: updateKey - summary: Update an API key - /oauth/clients/create: - post: - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/NewClientRequest' - description: Client created - tags: - - OAuth - operationId: createOAuthClient - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/NewClientRequest' - required: true - summary: Create a new OAuth client - '/oauth/clients/{apiID}': - get: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - items: - $ref: '#/components/schemas/NewClientRequest' - type: array - description: Get OAuth client details or a list of OAuth clients - tags: - - OAuth - operationId: listOAuthClients - summary: List all Oauth clients - '/oauth/clients/{apiID}/{keyName}': - delete: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - - description: The Client ID - in: path - name: keyName - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiModifyKeySuccess' - description: OAuth client deleted - tags: - - oauth - operationId: deleteOAuthClient - summary: Delete an oAuth client - get: - parameters: - - description: API ID - in: path - name: apiID - required: true - schema: - type: string - - description: The Client ID - in: path - name: keyName - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/NewClientRequest' - description: Get OAuth client details or a list of OAuth clients - tags: - - OAuth - operationId: getOAuthClient - summary: Retrieve an oAuth client - '/oauth/clients/{apiID}/{keyName}/tokens': - get: - parameters: - - description: The API ID - in: path - name: apiID - required: true - schema: - type: string - - description: The Client ID - in: path - name: keyName - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - items: - $ref: '#/components/schemas/OAuthClientToken' - type: array - description: Get a list of tokens - tags: - - OAuth - operationId: getOAuthClientTokens - summary: Get the tokens of an oAuth client - '/oauth/refresh/{keyName}': - delete: - parameters: - - description: The API id - in: query - name: api_id - required: true - schema: - type: string - - description: Refresh token - in: path - name: keyName - required: true - schema: - type: string - responses: - '200': - content: - application/json: - schema: - $ref: '#/components/schemas/apiModifyKeySuccess' - description: Deleted - tags: - - oauth - operationId: invalidateOAuthRefresh - summary: Invalidate oAuth refresh token - /reload: - get: - responses: - '200': - description: All gateways in a cluster were successfully refreshed - tags: - - Reload - operationId: resetHandler - summary: Reloads a single Tyk Gateway instance - /reload/group: - get: - responses: - '200': - description: All gateways in a cluster were successfully refreshed - tags: - - Reload - operationId: groupResetHandler - summary: Reloads all the Tyk Gateways in a cluster +paths: {} components: responses: parameterBodies: From 72e3bd60cbe820c277a87cecd3e8b9459b35ed2d Mon Sep 17 00:00:00 2001 From: Lanre Adelowo Date: Thu, 25 Apr 2019 13:15:12 +0100 Subject: [PATCH 20/20] Rename file update swagger.sh --- gateway-swagger.yaml => swagger.yml | 0 utils/ci-swagger.sh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename gateway-swagger.yaml => swagger.yml (100%) diff --git a/gateway-swagger.yaml b/swagger.yml similarity index 100% rename from gateway-swagger.yaml rename to swagger.yml diff --git a/utils/ci-swagger.sh b/utils/ci-swagger.sh index 4fd17b1c97f..a39403151f0 100755 --- a/utils/ci-swagger.sh +++ b/utils/ci-swagger.sh @@ -1,7 +1,7 @@ #!/bin/bash swagger2fileName="swagger2.yaml" -openAPIspecfileName="gateway-swagger.yaml" +openAPIspecfileName="swagger.yml" fatal() { echo "$@" >&2