mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 06:40:50 +01:00
minor spec cleanups (#45)
This commit is contained in:
parent
b951ea152d
commit
fe69a8094b
@ -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
|
||||
*/
|
||||
|
@ -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 {
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<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 {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'],
|
||||
|
Loading…
Reference in New Issue
Block a user