From fe69a8094b86e500a431eea3913d91ce30152e37 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 21 Sep 2023 12:57:14 -0400 Subject: [PATCH] minor spec cleanups (#45) --- rest_client_zrok/share/share_client.go | 40 ---------- rest_client_zrok/share/share_responses.go | 2 +- rest_server_zrok/embedded_spec.go | 80 +------------------ .../operations/share/share_responses.go | 2 +- rest_server_zrok/operations/zrok_api.go | 12 --- specs/zrok.yml | 5 +- ui/src/api/share.js | 22 ----- 7 files changed, 6 insertions(+), 157 deletions(-) diff --git a/rest_client_zrok/share/share_client.go b/rest_client_zrok/share/share_client.go index 96683a93..1f992f99 100644 --- a/rest_client_zrok/share/share_client.go +++ b/rest_client_zrok/share/share_client.go @@ -32,8 +32,6 @@ type ClientOption func(*runtime.ClientOperation) type ClientService interface { Access(params *AccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AccessCreated, error) - OauthAuthenticate(params *OauthAuthenticateParams, opts ...ClientOption) (*OauthAuthenticateOK, error) - Share(params *ShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ShareCreated, error) Unaccess(params *UnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnaccessOK, error) @@ -84,44 +82,6 @@ func (a *Client) Access(params *AccessParams, authInfo runtime.ClientAuthInfoWri panic(msg) } -/* -OauthAuthenticate oauth authenticate API -*/ -func (a *Client) OauthAuthenticate(params *OauthAuthenticateParams, opts ...ClientOption) (*OauthAuthenticateOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewOauthAuthenticateParams() - } - op := &runtime.ClientOperation{ - ID: "oauthAuthenticate", - Method: "GET", - PathPattern: "/oauth/authorize", - ProducesMediaTypes: []string{"application/zrok.v1+json"}, - ConsumesMediaTypes: []string{"application/zrok.v1+json"}, - Schemes: []string{"http"}, - Params: params, - Reader: &OauthAuthenticateReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*OauthAuthenticateOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for oauthAuthenticate: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - /* Share share API */ diff --git a/rest_client_zrok/share/share_responses.go b/rest_client_zrok/share/share_responses.go index 58e2b889..8e1c6150 100644 --- a/rest_client_zrok/share/share_responses.go +++ b/rest_client_zrok/share/share_responses.go @@ -231,7 +231,7 @@ func NewShareUnprocessableEntity() *ShareUnprocessableEntity { /* ShareUnprocessableEntity describes a response with status code 422, with default header values. -Unprocessable entity. Incorrect enum? +unprocessable */ type ShareUnprocessableEntity struct { } diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index e83a35b5..ee155ad8 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -702,44 +702,6 @@ func init() { } } }, - "/oauth/authorize": { - "get": { - "tags": [ - "share" - ], - "operationId": "oauthAuthenticate", - "parameters": [ - { - "type": "string", - "name": "state", - "in": "query" - }, - { - "type": "string", - "name": "code", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "testing" - }, - "302": { - "description": "redirect back to share", - "headers": { - "location": { - "type": "string", - "description": "Redirect URL" - } - } - }, - "500": { - "description": "internal server error" - } - } - } - }, "/overview": { "get": { "security": [ @@ -904,7 +866,7 @@ func init() { "description": "not found" }, "422": { - "description": "Unprocessable entity. Incorrect enum?" + "description": "unprocessable" }, "500": { "description": "internal server error", @@ -2356,44 +2318,6 @@ func init() { } } }, - "/oauth/authorize": { - "get": { - "tags": [ - "share" - ], - "operationId": "oauthAuthenticate", - "parameters": [ - { - "type": "string", - "name": "state", - "in": "query" - }, - { - "type": "string", - "name": "code", - "in": "query", - "required": true - } - ], - "responses": { - "200": { - "description": "testing" - }, - "302": { - "description": "redirect back to share", - "headers": { - "location": { - "type": "string", - "description": "Redirect URL" - } - } - }, - "500": { - "description": "internal server error" - } - } - } - }, "/overview": { "get": { "security": [ @@ -2558,7 +2482,7 @@ func init() { "description": "not found" }, "422": { - "description": "Unprocessable entity. Incorrect enum?" + "description": "unprocessable" }, "500": { "description": "internal server error", diff --git a/rest_server_zrok/operations/share/share_responses.go b/rest_server_zrok/operations/share/share_responses.go index 0dc208fa..d49c044e 100644 --- a/rest_server_zrok/operations/share/share_responses.go +++ b/rest_server_zrok/operations/share/share_responses.go @@ -112,7 +112,7 @@ func (o *ShareNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.P const ShareUnprocessableEntityCode int = 422 /* -ShareUnprocessableEntity Unprocessable entity. Incorrect enum? +ShareUnprocessableEntity unprocessable swagger:response shareUnprocessableEntity */ diff --git a/rest_server_zrok/operations/zrok_api.go b/rest_server_zrok/operations/zrok_api.go index 3ac58e9d..158e03c3 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -103,9 +103,6 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { AccountLoginHandler: account.LoginHandlerFunc(func(params account.LoginParams) middleware.Responder { return middleware.NotImplemented("operation account.Login has not yet been implemented") }), - ShareOauthAuthenticateHandler: share.OauthAuthenticateHandlerFunc(func(params share.OauthAuthenticateParams) middleware.Responder { - return middleware.NotImplemented("operation share.OauthAuthenticate has not yet been implemented") - }), MetadataOverviewHandler: metadata.OverviewHandlerFunc(func(params metadata.OverviewParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation metadata.Overview has not yet been implemented") }), @@ -225,8 +222,6 @@ type ZrokAPI struct { AdminListFrontendsHandler admin.ListFrontendsHandler // AccountLoginHandler sets the operation handler for the login operation AccountLoginHandler account.LoginHandler - // ShareOauthAuthenticateHandler sets the operation handler for the oauth authenticate operation - ShareOauthAuthenticateHandler share.OauthAuthenticateHandler // MetadataOverviewHandler sets the operation handler for the overview operation MetadataOverviewHandler metadata.OverviewHandler // AccountRegisterHandler sets the operation handler for the register operation @@ -384,9 +379,6 @@ func (o *ZrokAPI) Validate() error { if o.AccountLoginHandler == nil { unregistered = append(unregistered, "account.LoginHandler") } - if o.ShareOauthAuthenticateHandler == nil { - unregistered = append(unregistered, "share.OauthAuthenticateHandler") - } if o.MetadataOverviewHandler == nil { unregistered = append(unregistered, "metadata.OverviewHandler") } @@ -594,10 +586,6 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } - o.handlers["GET"]["/oauth/authorize"] = share.NewOauthAuthenticate(o.context, o.ShareOauthAuthenticateHandler) - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } o.handlers["GET"]["/overview"] = metadata.NewOverview(o.context, o.MetadataOverviewHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) diff --git a/specs/zrok.yml b/specs/zrok.yml index e4cac39b..88539ac1 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -578,7 +578,7 @@ paths: 404: description: not found 422: - description: Unprocessable entity. Incorrect enum? + description: unprocessable 500: description: internal server error schema: @@ -982,14 +982,13 @@ definitions: $ref: "#/definitions/authUser" oauthProvider: type: string - enum: [github,google] + enum: ["github", "google"] oauthEmailDomains: type: array items: type: string oauthAuthorizationCheckInterval: type: string - reserved: type: boolean diff --git a/ui/src/api/share.js b/ui/src/api/share.js index 7293eb23..3bf46930 100644 --- a/ui/src/api/share.js +++ b/ui/src/api/share.js @@ -17,23 +17,6 @@ export function access(options) { return gateway.request(accessOperation, parameters) } -/** - * @param {string} code - * @param {object} options Optional options - * @param {string} [options.state] - * @return {Promise} testing - */ -export function oauthAuthenticate(code, options) { - if (!options) options = {} - const parameters = { - query: { - state: options.state, - code - } - } - return gateway.request(oauthAuthenticateOperation, parameters) -} - /** * @param {object} options Optional options * @param {module:types.shareRequest} [options.body] @@ -105,11 +88,6 @@ const accessOperation = { ] } -const oauthAuthenticateOperation = { - path: '/oauth/authorize', - method: 'get' -} - const shareOperation = { path: '/share', contentTypes: ['application/zrok.v1+json'],