diff --git a/bin/generate_rest.sh b/bin/generate_rest.sh index f4b7d999..8e642723 100755 --- a/bin/generate_rest.sh +++ b/bin/generate_rest.sh @@ -7,11 +7,6 @@ command -v swagger >/dev/null 2>&1 || { exit 1 } -command -v openapi >/dev/null 2>&1 || { - echo >&2 "command 'openapi' not installed. see: https://www.npmjs.com/package/openapi-client for installation" - exit 1 -} - command -v swagger-codegen 2>&1 || { echo >&2 "command 'swagger-codegen' not installed. see: https://github.com/swagger-api/swagger-codegen for installation" exit 1 @@ -42,11 +37,8 @@ swagger generate server -P rest_model_zrok.Principal -f "$zrokSpec" -s rest_serv echo "...generating zrok client" swagger generate client -P rest_model_zrok.Principal -f "$zrokSpec" -c rest_client_zrok -t "$zrokDir" -m "rest_model_zrok" -echo "...generating api console js client" -openapi -s specs/zrok.yml -o ui/src/api -l js - -echo "...generating ui100 api console ts client" -openapi-generator-cli generate -i specs/zrok.yml -o ui100/src/api -g typescript-fetch +echo "...generating ui api console ts client" +openapi-generator-cli generate -i specs/zrok.yml -o ui/src/api -g typescript-fetch echo "...generating agent console js client" openapi-generator-cli generate -i agent/agentGrpc/agent.swagger.json -o agent/agentUi/src/api -g typescript-fetch diff --git a/controller/invite.go b/controller/invite.go index 57dd5851..3736df88 100644 --- a/controller/invite.go +++ b/controller/invite.go @@ -24,7 +24,7 @@ func (h *inviteHandler) Handle(params account.InviteParams) middleware.Responder logrus.Warnf("not accepting invites; attempt from '%v'", params.Body.Email) return account.NewInviteBadRequest() } - if params.Body == nil || params.Body.Email == "" { + if params.Body.Email == "" { logrus.Errorf("missing email") return account.NewInviteBadRequest() } diff --git a/rest_client_zrok/account/invite_parameters.go b/rest_client_zrok/account/invite_parameters.go index 5b7baaa1..cbadcd7f 100644 --- a/rest_client_zrok/account/invite_parameters.go +++ b/rest_client_zrok/account/invite_parameters.go @@ -14,8 +14,6 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - - "github.com/openziti/zrok/rest_model_zrok" ) // NewInviteParams creates a new InviteParams object, @@ -64,7 +62,7 @@ InviteParams contains all the parameters to send to the API endpoint type InviteParams struct { // Body. - Body *rest_model_zrok.InviteRequest + Body InviteBody timeout time.Duration Context context.Context @@ -120,13 +118,13 @@ func (o *InviteParams) SetHTTPClient(client *http.Client) { } // WithBody adds the body to the invite params -func (o *InviteParams) WithBody(body *rest_model_zrok.InviteRequest) *InviteParams { +func (o *InviteParams) WithBody(body InviteBody) *InviteParams { o.SetBody(body) return o } // SetBody adds the body to the invite params -func (o *InviteParams) SetBody(body *rest_model_zrok.InviteRequest) { +func (o *InviteParams) SetBody(body InviteBody) { o.Body = body } @@ -137,10 +135,8 @@ func (o *InviteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Regist return err } var res []error - if o.Body != nil { - if err := r.SetBodyParam(o.Body); err != nil { - return err - } + if err := r.SetBodyParam(o.Body); err != nil { + return err } if len(res) > 0 { diff --git a/rest_client_zrok/account/invite_responses.go b/rest_client_zrok/account/invite_responses.go index a07d98a3..9124e4c3 100644 --- a/rest_client_zrok/account/invite_responses.go +++ b/rest_client_zrok/account/invite_responses.go @@ -6,11 +6,13 @@ package account // Editing this file might prove futile when you re-run the swagger generate command import ( + "context" "fmt" "io" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" "github.com/openziti/zrok/rest_model_zrok" ) @@ -285,3 +287,44 @@ func (o *InviteInternalServerError) readResponse(response runtime.ClientResponse return nil } + +/* +InviteBody invite body +swagger:model InviteBody +*/ +type InviteBody struct { + + // email + Email string `json:"email,omitempty"` + + // token + Token string `json:"token,omitempty"` +} + +// Validate validates this invite body +func (o *InviteBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this invite body based on context it is used +func (o *InviteBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *InviteBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *InviteBody) UnmarshalBinary(b []byte) error { + var res InviteBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index 30a4042b..9dafa400 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -634,7 +634,14 @@ func init() { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/inviteRequest" + "properties": { + "email": { + "type": "string" + }, + "token": { + "type": "string" + } + } } } ], @@ -1887,17 +1894,6 @@ func init() { "$ref": "#/definitions/frontend" } }, - "inviteRequest": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, "inviteTokenGenerateRequest": { "type": "object", "properties": { @@ -2939,7 +2935,14 @@ func init() { "name": "body", "in": "body", "schema": { - "$ref": "#/definitions/inviteRequest" + "properties": { + "email": { + "type": "string" + }, + "token": { + "type": "string" + } + } } } ], @@ -4194,17 +4197,6 @@ func init() { "$ref": "#/definitions/frontend" } }, - "inviteRequest": { - "type": "object", - "properties": { - "email": { - "type": "string" - }, - "token": { - "type": "string" - } - } - }, "inviteTokenGenerateRequest": { "type": "object", "properties": { diff --git a/rest_server_zrok/operations/account/invite.go b/rest_server_zrok/operations/account/invite.go index de2b7770..b5ea4d93 100644 --- a/rest_server_zrok/operations/account/invite.go +++ b/rest_server_zrok/operations/account/invite.go @@ -6,9 +6,12 @@ package account // Editing this file might prove futile when you re-run the generate command import ( + "context" "net/http" "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // InviteHandlerFunc turns a function with the right signature into a invite handler @@ -54,3 +57,43 @@ func (o *Invite) ServeHTTP(rw http.ResponseWriter, r *http.Request) { o.Context.Respond(rw, r, route.Produces, route, res) } + +// InviteBody invite body +// +// swagger:model InviteBody +type InviteBody struct { + + // email + Email string `json:"email,omitempty"` + + // token + Token string `json:"token,omitempty"` +} + +// Validate validates this invite body +func (o *InviteBody) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this invite body based on context it is used +func (o *InviteBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (o *InviteBody) MarshalBinary() ([]byte, error) { + if o == nil { + return nil, nil + } + return swag.WriteJSON(o) +} + +// UnmarshalBinary interface implementation +func (o *InviteBody) UnmarshalBinary(b []byte) error { + var res InviteBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *o = res + return nil +} diff --git a/rest_server_zrok/operations/account/invite_parameters.go b/rest_server_zrok/operations/account/invite_parameters.go index 5f50d4cd..dc33f889 100644 --- a/rest_server_zrok/operations/account/invite_parameters.go +++ b/rest_server_zrok/operations/account/invite_parameters.go @@ -12,8 +12,6 @@ import ( "github.com/go-openapi/runtime" "github.com/go-openapi/runtime/middleware" "github.com/go-openapi/validate" - - "github.com/openziti/zrok/rest_model_zrok" ) // NewInviteParams creates a new InviteParams object @@ -36,7 +34,7 @@ type InviteParams struct { /* In: body */ - Body *rest_model_zrok.InviteRequest + Body InviteBody } // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface @@ -50,7 +48,7 @@ func (o *InviteParams) BindRequest(r *http.Request, route *middleware.MatchedRou if runtime.HasBody(r) { defer r.Body.Close() - var body rest_model_zrok.InviteRequest + var body InviteBody if err := route.Consumer.Consume(r.Body, &body); err != nil { res = append(res, errors.NewParseError("body", "body", "", err)) } else { @@ -65,7 +63,7 @@ func (o *InviteParams) BindRequest(r *http.Request, route *middleware.MatchedRou } if len(res) == 0 { - o.Body = &body + o.Body = body } } } diff --git a/sdk/python/sdk/zrok/zrok_api/__init__.py b/sdk/python/sdk/zrok/zrok_api/__init__.py index 0bd11dfa..2d4e22f6 100644 --- a/sdk/python/sdk/zrok/zrok_api/__init__.py +++ b/sdk/python/sdk/zrok/zrok_api/__init__.py @@ -53,7 +53,7 @@ from zrok_api.models.inline_response2003 import InlineResponse2003 from zrok_api.models.inline_response2003_memberships import InlineResponse2003Memberships from zrok_api.models.inline_response2004 import InlineResponse2004 from zrok_api.models.inline_response201 import InlineResponse201 -from zrok_api.models.invite_request import InviteRequest +from zrok_api.models.invite_body import InviteBody from zrok_api.models.invite_token_generate_request import InviteTokenGenerateRequest from zrok_api.models.login_request import LoginRequest from zrok_api.models.login_response import LoginResponse diff --git a/sdk/python/sdk/zrok/zrok_api/api/account_api.py b/sdk/python/sdk/zrok/zrok_api/api/account_api.py index 61006311..26a98ac2 100644 --- a/sdk/python/sdk/zrok/zrok_api/api/account_api.py +++ b/sdk/python/sdk/zrok/zrok_api/api/account_api.py @@ -134,7 +134,7 @@ class AccountApi(object): >>> result = thread.get() :param async_req bool - :param InviteRequest body: + :param InviteBody body: :return: None If the method is called asynchronously, returns the request thread. @@ -155,7 +155,7 @@ class AccountApi(object): >>> result = thread.get() :param async_req bool - :param InviteRequest body: + :param InviteBody body: :return: None If the method is called asynchronously, returns the request thread. diff --git a/sdk/python/sdk/zrok/zrok_api/models/__init__.py b/sdk/python/sdk/zrok/zrok_api/models/__init__.py index 5904d90f..ee476087 100644 --- a/sdk/python/sdk/zrok/zrok_api/models/__init__.py +++ b/sdk/python/sdk/zrok/zrok_api/models/__init__.py @@ -43,7 +43,7 @@ from zrok_api.models.inline_response2003 import InlineResponse2003 from zrok_api.models.inline_response2003_memberships import InlineResponse2003Memberships from zrok_api.models.inline_response2004 import InlineResponse2004 from zrok_api.models.inline_response201 import InlineResponse201 -from zrok_api.models.invite_request import InviteRequest +from zrok_api.models.invite_body import InviteBody from zrok_api.models.invite_token_generate_request import InviteTokenGenerateRequest from zrok_api.models.login_request import LoginRequest from zrok_api.models.login_response import LoginResponse diff --git a/sdk/python/sdk/zrok/zrok_api/models/invite_body.py b/sdk/python/sdk/zrok/zrok_api/models/invite_body.py new file mode 100644 index 00000000..359ca1a2 --- /dev/null +++ b/sdk/python/sdk/zrok/zrok_api/models/invite_body.py @@ -0,0 +1,136 @@ +# coding: utf-8 + +""" + zrok + + zrok client access # noqa: E501 + + OpenAPI spec version: 1.0.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + +import pprint +import re # noqa: F401 + +import six + +class InviteBody(object): + """NOTE: This class is auto generated by the swagger code generator program. + + Do not edit the class manually. + """ + """ + Attributes: + swagger_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + swagger_types = { + 'email': 'str', + 'token': 'str' + } + + attribute_map = { + 'email': 'email', + 'token': 'token' + } + + def __init__(self, email=None, token=None): # noqa: E501 + """InviteBody - a model defined in Swagger""" # noqa: E501 + self._email = None + self._token = None + self.discriminator = None + if email is not None: + self.email = email + if token is not None: + self.token = token + + @property + def email(self): + """Gets the email of this InviteBody. # noqa: E501 + + + :return: The email of this InviteBody. # noqa: E501 + :rtype: str + """ + return self._email + + @email.setter + def email(self, email): + """Sets the email of this InviteBody. + + + :param email: The email of this InviteBody. # noqa: E501 + :type: str + """ + + self._email = email + + @property + def token(self): + """Gets the token of this InviteBody. # noqa: E501 + + + :return: The token of this InviteBody. # noqa: E501 + :rtype: str + """ + return self._token + + @token.setter + def token(self, token): + """Sets the token of this InviteBody. + + + :param token: The token of this InviteBody. # noqa: E501 + :type: str + """ + + self._token = token + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + if issubclass(InviteBody, dict): + for key, value in self.items(): + result[key] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, InviteBody): + return False + + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """Returns true if both objects are not equal""" + return not self == other diff --git a/specs/zrok.yml b/specs/zrok.yml index 5f34ee44..36571c16 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -56,7 +56,11 @@ paths: - name: body in: body schema: - $ref: "#/definitions/inviteRequest" + properties: + email: + type: string + token: + type: string responses: 201: description: invitation created @@ -1198,14 +1202,6 @@ definitions: items: type: string - inviteRequest: - type: object - properties: - email: - type: string - token: - type: string - loginRequest: type: object properties: diff --git a/ui/src/api/.openapi-generator/FILES b/ui/src/api/.openapi-generator/FILES index 87fd2391..902cff0b 100644 --- a/ui/src/api/.openapi-generator/FILES +++ b/ui/src/api/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.openapi-generator-ignore apis/AccountApi.ts apis/AdminApi.ts apis/EnvironmentApi.ts