From cb61aac1f3d5d2ce1fd2d00a5c50aafd5c9509ca Mon Sep 17 00:00:00 2001 From: Lucas Kacher Date: Sat, 3 Aug 2024 15:41:11 -0700 Subject: [PATCH] feat: spec updated --- Makefile | 2 + client/client.gen.go | 159 +----------------------------------------- spec/openapi-3.0.json | 86 +++-------------------- spec/openapi.json | 84 +++------------------- 4 files changed, 26 insertions(+), 305 deletions(-) diff --git a/Makefile b/Makefile index c6fb3da..55e808b 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ install-tools: fetch-spec: curl --silent "https://api.artifactsmmo.com/openapi.json" | jq . > spec/openapi.json +all: install-tools fetch-spec process-spec generate-client test + process-spec: openapi-down-convert --input spec/openapi.json --output spec/openapi-3.0.json sed -i '' 's/"type": "null"/"nullable": true/g' spec/openapi-3.0.json diff --git a/client/client.gen.go b/client/client.gen.go index 23908c4..0675059 100644 --- a/client/client.gen.go +++ b/client/client.gen.go @@ -673,6 +673,9 @@ type CooldownSchema struct { // RemainingSeconds Deprecated** The remaining seconds of the cooldown. RemainingSeconds int `json:"remainingSeconds"` + // StartedAt The start of the cooldown. + StartedAt time.Time `json:"started_at"` + // TotalSeconds Deprecated** The total seconds of the cooldown. TotalSeconds int `json:"totalSeconds"` } @@ -1983,15 +1986,6 @@ type GetAllCharactersLogsMyLogsGetParams struct { Size *int `form:"size,omitempty" json:"size,omitempty"` } -// GetCharacterLogsMyNameLogsGetParams defines parameters for GetCharacterLogsMyNameLogsGet. -type GetCharacterLogsMyNameLogsGetParams struct { - // Page Page number - Page *int `form:"page,omitempty" json:"page,omitempty"` - - // Size Page size - Size *int `form:"size,omitempty" json:"size,omitempty"` -} - // GetAllResourcesResourcesGetParams defines parameters for GetAllResourcesResourcesGet. type GetAllResourcesResourcesGetParams struct { // MinLevel Skill minimum level. @@ -4938,9 +4932,6 @@ type ClientInterface interface { ActionUnequipItemMyNameActionUnequipPost(ctx context.Context, name string, body ActionUnequipItemMyNameActionUnequipPostJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetCharacterLogsMyNameLogsGet request - GetCharacterLogsMyNameLogsGet(ctx context.Context, name string, params *GetCharacterLogsMyNameLogsGetParams, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetAllResourcesResourcesGet request GetAllResourcesResourcesGet(ctx context.Context, params *GetAllResourcesResourcesGetParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -5563,18 +5554,6 @@ func (c *Client) ActionUnequipItemMyNameActionUnequipPost(ctx context.Context, n return c.Client.Do(req) } -func (c *Client) GetCharacterLogsMyNameLogsGet(ctx context.Context, name string, params *GetCharacterLogsMyNameLogsGetParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetCharacterLogsMyNameLogsGetRequest(c.Server, name, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - func (c *Client) GetAllResourcesResourcesGet(ctx context.Context, params *GetAllResourcesResourcesGetParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetAllResourcesResourcesGetRequest(c.Server, params) if err != nil { @@ -7451,78 +7430,6 @@ func NewActionUnequipItemMyNameActionUnequipPostRequestWithBody(server string, n return req, nil } -// NewGetCharacterLogsMyNameLogsGetRequest generates requests for GetCharacterLogsMyNameLogsGet -func NewGetCharacterLogsMyNameLogsGetRequest(server string, name string, params *GetCharacterLogsMyNameLogsGetParams) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "name", runtime.ParamLocationPath, name) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/my/%s/logs", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - if params != nil { - queryValues := queryURL.Query() - - if params.Page != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "page", runtime.ParamLocationQuery, *params.Page); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Size != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "size", runtime.ParamLocationQuery, *params.Size); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - // NewGetAllResourcesResourcesGetRequest generates requests for GetAllResourcesResourcesGet func NewGetAllResourcesResourcesGetRequest(server string, params *GetAllResourcesResourcesGetParams) (*http.Request, error) { var err error @@ -7894,9 +7801,6 @@ type ClientWithResponsesInterface interface { ActionUnequipItemMyNameActionUnequipPostWithResponse(ctx context.Context, name string, body ActionUnequipItemMyNameActionUnequipPostJSONRequestBody, reqEditors ...RequestEditorFn) (*ActionUnequipItemMyNameActionUnequipPostResponse, error) - // GetCharacterLogsMyNameLogsGetWithResponse request - GetCharacterLogsMyNameLogsGetWithResponse(ctx context.Context, name string, params *GetCharacterLogsMyNameLogsGetParams, reqEditors ...RequestEditorFn) (*GetCharacterLogsMyNameLogsGetResponse, error) - // GetAllResourcesResourcesGetWithResponse request GetAllResourcesResourcesGetWithResponse(ctx context.Context, params *GetAllResourcesResourcesGetParams, reqEditors ...RequestEditorFn) (*GetAllResourcesResourcesGetResponse, error) @@ -8699,28 +8603,6 @@ func (r ActionUnequipItemMyNameActionUnequipPostResponse) StatusCode() int { return 0 } -type GetCharacterLogsMyNameLogsGetResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DataPageLogSchema -} - -// Status returns HTTPResponse.Status -func (r GetCharacterLogsMyNameLogsGetResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r GetCharacterLogsMyNameLogsGetResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - type GetAllResourcesResourcesGetResponse struct { Body []byte HTTPResponse *http.Response @@ -9231,15 +9113,6 @@ func (c *ClientWithResponses) ActionUnequipItemMyNameActionUnequipPostWithRespon return ParseActionUnequipItemMyNameActionUnequipPostResponse(rsp) } -// GetCharacterLogsMyNameLogsGetWithResponse request returning *GetCharacterLogsMyNameLogsGetResponse -func (c *ClientWithResponses) GetCharacterLogsMyNameLogsGetWithResponse(ctx context.Context, name string, params *GetCharacterLogsMyNameLogsGetParams, reqEditors ...RequestEditorFn) (*GetCharacterLogsMyNameLogsGetResponse, error) { - rsp, err := c.GetCharacterLogsMyNameLogsGet(ctx, name, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCharacterLogsMyNameLogsGetResponse(rsp) -} - // GetAllResourcesResourcesGetWithResponse request returning *GetAllResourcesResourcesGetResponse func (c *ClientWithResponses) GetAllResourcesResourcesGetWithResponse(ctx context.Context, params *GetAllResourcesResourcesGetParams, reqEditors ...RequestEditorFn) (*GetAllResourcesResourcesGetResponse, error) { rsp, err := c.GetAllResourcesResourcesGet(ctx, params, reqEditors...) @@ -10203,32 +10076,6 @@ func ParseActionUnequipItemMyNameActionUnequipPostResponse(rsp *http.Response) ( return response, nil } -// ParseGetCharacterLogsMyNameLogsGetResponse parses an HTTP response from a GetCharacterLogsMyNameLogsGetWithResponse call -func ParseGetCharacterLogsMyNameLogsGetResponse(rsp *http.Response) (*GetCharacterLogsMyNameLogsGetResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &GetCharacterLogsMyNameLogsGetResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DataPageLogSchema - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - } - - return response, nil -} - // ParseGetAllResourcesResourcesGetResponse parses an HTTP response from a GetAllResourcesResourcesGetWithResponse call func ParseGetAllResourcesResourcesGetResponse(rsp *http.Response) (*GetAllResourcesResourcesGetResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/spec/openapi-3.0.json b/spec/openapi-3.0.json index c527413..9753527 100644 --- a/spec/openapi-3.0.json +++ b/spec/openapi-3.0.json @@ -1147,80 +1147,6 @@ } } }, - "/my/{name}/logs": { - "get": { - "tags": [ - "My characters" - ], - "summary": "Get Character Logs", - "description": "History of your character's last 100 actions.", - "operationId": "get_character_logs_my__name__logs_get", - "security": [ - { - "JWTBearer": [] - } - ], - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "pattern": "^[a-zA-Z0-9_-]+$", - "title": "Character name", - "description": "Name of your character." - }, - "description": "Name of your character." - }, - { - "name": "page", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "minimum": 1, - "description": "Page number", - "default": 1, - "title": "Page" - }, - "description": "Page number" - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "description": "Page size", - "default": 50, - "title": "Size" - }, - "description": "Page size" - } - ], - "responses": { - "200": { - "description": "Successfully fetched logs.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DataPage_LogSchema_" - } - } - } - }, - "404": { - "description": "Logs not found." - }, - "498": { - "description": "Character not found." - } - } - } - }, "/my/logs": { "get": { "tags": [ @@ -1276,6 +1202,9 @@ }, "404": { "description": "Logs not found." + }, + "498": { + "description": "Character not found." } } } @@ -3440,6 +3369,12 @@ "title": "Remainingseconds", "description": "Deprecated** The remaining seconds of the cooldown." }, + "started_at": { + "type": "string", + "format": "date-time", + "title": "Started At", + "description": "The start of the cooldown." + }, "expiration": { "type": "string", "format": "date-time", @@ -3473,6 +3408,7 @@ "remaining_seconds", "totalSeconds", "remainingSeconds", + "started_at", "expiration", "reason" ], @@ -5745,4 +5681,4 @@ } } } -} \ No newline at end of file +} diff --git a/spec/openapi.json b/spec/openapi.json index bd84eb1..853bf91 100644 --- a/spec/openapi.json +++ b/spec/openapi.json @@ -1147,80 +1147,6 @@ } } }, - "/my/{name}/logs": { - "get": { - "tags": [ - "My characters" - ], - "summary": "Get Character Logs", - "description": "History of your character's last 100 actions.", - "operationId": "get_character_logs_my__name__logs_get", - "security": [ - { - "JWTBearer": [] - } - ], - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string", - "pattern": "^[a-zA-Z0-9_-]+$", - "title": "Character name", - "description": "Name of your character." - }, - "description": "Name of your character." - }, - { - "name": "page", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "minimum": 1, - "description": "Page number", - "default": 1, - "title": "Page" - }, - "description": "Page number" - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "minimum": 1, - "description": "Page size", - "default": 50, - "title": "Size" - }, - "description": "Page size" - } - ], - "responses": { - "200": { - "description": "Successfully fetched logs.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DataPage_LogSchema_" - } - } - } - }, - "404": { - "description": "Logs not found." - }, - "498": { - "description": "Character not found." - } - } - } - }, "/my/logs": { "get": { "tags": [ @@ -1276,6 +1202,9 @@ }, "404": { "description": "Logs not found." + }, + "498": { + "description": "Character not found." } } } @@ -3450,6 +3379,12 @@ "title": "Remainingseconds", "description": "Deprecated** The remaining seconds of the cooldown." }, + "started_at": { + "type": "string", + "format": "date-time", + "title": "Started At", + "description": "The start of the cooldown." + }, "expiration": { "type": "string", "format": "date-time", @@ -3483,6 +3418,7 @@ "remaining_seconds", "totalSeconds", "remainingSeconds", + "started_at", "expiration", "reason" ],