update openapi spec to allow auth scheme and users to be sent for 'tunnel' request (#12)

This commit is contained in:
Michael Quigley 2022-08-16 11:46:54 -04:00
parent f736ef3b96
commit cb3fef21d4
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
5 changed files with 190 additions and 1 deletions

View File

@ -0,0 +1,53 @@
// Code generated by go-swagger; DO NOT EDIT.
package rest_model_zrok
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// AuthUser auth user
//
// swagger:model authUser
type AuthUser struct {
// password
Password string `json:"password,omitempty"`
// username
Username string `json:"username,omitempty"`
}
// Validate validates this auth user
func (m *AuthUser) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this auth user based on context it is used
func (m *AuthUser) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *AuthUser) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *AuthUser) UnmarshalBinary(b []byte) error {
var res AuthUser
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -7,7 +7,9 @@ package rest_model_zrok
import ( import (
"context" "context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt" "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag" "github.com/go-openapi/swag"
) )
@ -17,6 +19,12 @@ import (
// swagger:model tunnelRequest // swagger:model tunnelRequest
type TunnelRequest struct { type TunnelRequest struct {
// auth scheme
AuthScheme string `json:"authScheme,omitempty"`
// auth users
AuthUsers []*AuthUser `json:"authUsers"`
// endpoint // endpoint
Endpoint string `json:"endpoint,omitempty"` Endpoint string `json:"endpoint,omitempty"`
@ -26,11 +34,75 @@ type TunnelRequest struct {
// Validate validates this tunnel request // Validate validates this tunnel request
func (m *TunnelRequest) Validate(formats strfmt.Registry) error { func (m *TunnelRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAuthUsers(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil return nil
} }
// ContextValidate validates this tunnel request based on context it is used func (m *TunnelRequest) validateAuthUsers(formats strfmt.Registry) error {
if swag.IsZero(m.AuthUsers) { // not required
return nil
}
for i := 0; i < len(m.AuthUsers); i++ {
if swag.IsZero(m.AuthUsers[i]) { // not required
continue
}
if m.AuthUsers[i] != nil {
if err := m.AuthUsers[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("authUsers" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("authUsers" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this tunnel request based on the context it is used
func (m *TunnelRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { func (m *TunnelRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateAuthUsers(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TunnelRequest) contextValidateAuthUsers(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.AuthUsers); i++ {
if m.AuthUsers[i] != nil {
if err := m.AuthUsers[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("authUsers" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("authUsers" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil return nil
} }

View File

@ -287,6 +287,17 @@ func init() {
} }
} }
}, },
"authUser": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"enableRequest": { "enableRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -418,6 +429,15 @@ func init() {
"tunnelRequest": { "tunnelRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"authScheme": {
"type": "string"
},
"authUsers": {
"type": "array",
"items": {
"$ref": "#/definitions/authUser"
}
},
"endpoint": { "endpoint": {
"type": "string" "type": "string"
}, },
@ -730,6 +750,17 @@ func init() {
} }
} }
}, },
"authUser": {
"type": "object",
"properties": {
"password": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"enableRequest": { "enableRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -861,6 +892,15 @@ func init() {
"tunnelRequest": { "tunnelRequest": {
"type": "object", "type": "object",
"properties": { "properties": {
"authScheme": {
"type": "string"
},
"authUsers": {
"type": "array",
"items": {
"$ref": "#/definitions/authUser"
}
},
"endpoint": { "endpoint": {
"type": "string" "type": "string"
}, },

View File

@ -171,6 +171,14 @@ definitions:
token: token:
type: string type: string
authUser:
type: object
properties:
username:
type: string
password:
type: string
enableRequest: enableRequest:
type: object type: object
properties: properties:
@ -268,6 +276,12 @@ definitions:
type: string type: string
endpoint: endpoint:
type: string type: string
authScheme:
type: string
authUsers:
type: array
items:
$ref: "#/definitions/authUser"
tunnelResponse: tunnelResponse:
type: object type: object
properties: properties:

View File

@ -16,6 +16,14 @@
* @property {string} token * @property {string} token
*/ */
/**
* @typedef authUser
* @memberof module:types
*
* @property {string} username
* @property {string} password
*/
/** /**
* @typedef enableRequest * @typedef enableRequest
* @memberof module:types * @memberof module:types
@ -87,6 +95,8 @@
* *
* @property {string} zitiIdentityId * @property {string} zitiIdentityId
* @property {string} endpoint * @property {string} endpoint
* @property {string} authScheme
* @property {module:types.authUser[]} authUsers
*/ */
/** /**