minor spec cleanups (#45)

This commit is contained in:
Michael Quigley 2023-09-21 12:57:14 -04:00
parent b951ea152d
commit fe69a8094b
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
7 changed files with 6 additions and 157 deletions

View File

@ -32,8 +32,6 @@ type ClientOption func(*runtime.ClientOperation)
type ClientService interface { type ClientService interface {
Access(params *AccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*AccessCreated, error) 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) Share(params *ShareParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ShareCreated, error)
Unaccess(params *UnaccessParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*UnaccessOK, 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) 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 Share share API
*/ */

View File

@ -231,7 +231,7 @@ func NewShareUnprocessableEntity() *ShareUnprocessableEntity {
/* /*
ShareUnprocessableEntity describes a response with status code 422, with default header values. ShareUnprocessableEntity describes a response with status code 422, with default header values.
Unprocessable entity. Incorrect enum? unprocessable
*/ */
type ShareUnprocessableEntity struct { type ShareUnprocessableEntity struct {
} }

View File

@ -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": { "/overview": {
"get": { "get": {
"security": [ "security": [
@ -904,7 +866,7 @@ func init() {
"description": "not found" "description": "not found"
}, },
"422": { "422": {
"description": "Unprocessable entity. Incorrect enum?" "description": "unprocessable"
}, },
"500": { "500": {
"description": "internal server error", "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": { "/overview": {
"get": { "get": {
"security": [ "security": [
@ -2558,7 +2482,7 @@ func init() {
"description": "not found" "description": "not found"
}, },
"422": { "422": {
"description": "Unprocessable entity. Incorrect enum?" "description": "unprocessable"
}, },
"500": { "500": {
"description": "internal server error", "description": "internal server error",

View File

@ -112,7 +112,7 @@ func (o *ShareNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.P
const ShareUnprocessableEntityCode int = 422 const ShareUnprocessableEntityCode int = 422
/* /*
ShareUnprocessableEntity Unprocessable entity. Incorrect enum? ShareUnprocessableEntity unprocessable
swagger:response shareUnprocessableEntity swagger:response shareUnprocessableEntity
*/ */

View File

@ -103,9 +103,6 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
AccountLoginHandler: account.LoginHandlerFunc(func(params account.LoginParams) middleware.Responder { AccountLoginHandler: account.LoginHandlerFunc(func(params account.LoginParams) middleware.Responder {
return middleware.NotImplemented("operation account.Login has not yet been implemented") 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 { 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") return middleware.NotImplemented("operation metadata.Overview has not yet been implemented")
}), }),
@ -225,8 +222,6 @@ type ZrokAPI struct {
AdminListFrontendsHandler admin.ListFrontendsHandler AdminListFrontendsHandler admin.ListFrontendsHandler
// AccountLoginHandler sets the operation handler for the login operation // AccountLoginHandler sets the operation handler for the login operation
AccountLoginHandler account.LoginHandler 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 sets the operation handler for the overview operation
MetadataOverviewHandler metadata.OverviewHandler MetadataOverviewHandler metadata.OverviewHandler
// AccountRegisterHandler sets the operation handler for the register operation // AccountRegisterHandler sets the operation handler for the register operation
@ -384,9 +379,6 @@ func (o *ZrokAPI) Validate() error {
if o.AccountLoginHandler == nil { if o.AccountLoginHandler == nil {
unregistered = append(unregistered, "account.LoginHandler") unregistered = append(unregistered, "account.LoginHandler")
} }
if o.ShareOauthAuthenticateHandler == nil {
unregistered = append(unregistered, "share.OauthAuthenticateHandler")
}
if o.MetadataOverviewHandler == nil { if o.MetadataOverviewHandler == nil {
unregistered = append(unregistered, "metadata.OverviewHandler") unregistered = append(unregistered, "metadata.OverviewHandler")
} }
@ -594,10 +586,6 @@ func (o *ZrokAPI) initHandlerCache() {
if o.handlers["GET"] == nil { if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler) 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) o.handlers["GET"]["/overview"] = metadata.NewOverview(o.context, o.MetadataOverviewHandler)
if o.handlers["POST"] == nil { if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler) o.handlers["POST"] = make(map[string]http.Handler)

View File

@ -578,7 +578,7 @@ paths:
404: 404:
description: not found description: not found
422: 422:
description: Unprocessable entity. Incorrect enum? description: unprocessable
500: 500:
description: internal server error description: internal server error
schema: schema:
@ -982,14 +982,13 @@ definitions:
$ref: "#/definitions/authUser" $ref: "#/definitions/authUser"
oauthProvider: oauthProvider:
type: string type: string
enum: [github,google] enum: ["github", "google"]
oauthEmailDomains: oauthEmailDomains:
type: array type: array
items: items:
type: string type: string
oauthAuthorizationCheckInterval: oauthAuthorizationCheckInterval:
type: string type: string
reserved: reserved:
type: boolean type: boolean

View File

@ -17,23 +17,6 @@ export function access(options) {
return gateway.request(accessOperation, parameters) return gateway.request(accessOperation, parameters)
} }
/**
* @param {string} code
* @param {object} options Optional options
* @param {string} [options.state]
* @return {Promise<object>} 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 {object} options Optional options
* @param {module:types.shareRequest} [options.body] * @param {module:types.shareRequest} [options.body]
@ -105,11 +88,6 @@ const accessOperation = {
] ]
} }
const oauthAuthenticateOperation = {
path: '/oauth/authorize',
method: 'get'
}
const shareOperation = { const shareOperation = {
path: '/share', path: '/share',
contentTypes: ['application/zrok.v1+json'], contentTypes: ['application/zrok.v1+json'],