Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1 ommits put and delete requests #70

Closed
bryanjtc opened this issue Apr 17, 2024 · 5 comments · Fixed by #74
Closed

V1 ommits put and delete requests #70

bryanjtc opened this issue Apr 17, 2024 · 5 comments · Fixed by #74
Labels
bug Something isn't working

Comments

@bryanjtc
Copy link
Contributor

bryanjtc commented Apr 17, 2024

Here are some examples. The last one is not being generated.

"/api/v1/Catalogs/GetByStatus/{status}": {
      "get": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Returns catalogs by status. (Auth)",
        "operationId": "GetCatalogsByStatus",
        "parameters": [
          {
            "name": "status",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogs"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing GetByStatus"
          }
        }
      }
    },
    "/api/v1/Catalogs/GetByDescription/{description}": {
      "get": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Returns catalogs by description. (Auth)",
        "operationId": "GetCatalogsByDescription",
        "parameters": [
          {
            "name": "description",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogs"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing GetByStatus"
          }
        }
      }
    },
    "/api/v1/Catalogs/GroupByColumn/{column}": {
      "get": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Returns catalogs by column. (Auth)",
        "operationId": "GetCatalogsGroupByColumn",
        "parameters": [
          {
            "name": "column",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogs"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing GroupByColumn"
          }
        }
      }
    },
    "/api/v1/Catalogs/{type}": {
      "get": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Returns catalogs by type. (Auth)",
        "operationId": "GetCatalogs",
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Catalogs"
                  }
                }
              }
            }
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing GetCatalogs"
          }
        }
      }
    },
    "/api/v1/Catalogs": {
      "post": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Create a new catalog. (Auth)",
        "operationId": "PostCatalogs",
        "parameters": [
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Catalogs"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Catalog created succesfully."
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing PostCatalogs"
          }
        }
      }
    },
    "/api/v1/Catalogs/{sequential}": {
      "put": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Update an existing catalog. (Auth)",
        "operationId": "PutCatalogs",
        "parameters": [
          {
            "name": "sequential",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Catalogs"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Catalog updated succesfully."
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing PutCatalogs"
          }
        }
      },
      "delete": {
        "tags": [
          "Catalogs"
        ],
        "summary": "Delete an existing catalog. (Auth)",
        "operationId": "DeleteCatalogs",
        "parameters": [
          {
            "name": "sequential",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "X-DB-Catalog",
            "in": "header",
            "description": "Database catalog",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog deleted succesfully."
          },
          "400": {
            "description": "No results found."
          },
          "404": {
            "description": "An error occurred while executing DeleteCatalogs"
          }
        }
      }
    },

queries.ts output

export const useCatalogsServiceGetCatalogsByStatus = <TData = Common.CatalogsServiceGetCatalogsByStatusDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ status, xDbCatalog }: {
    status: string;
    xDbCatalog: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn" | "initialData">) => useQuery<TData, TError>({ queryKey: [Common.useCatalogsServiceGetCatalogsByStatusKey, ...(queryKey ?? [{ status, xDbCatalog }])], queryFn: () => CatalogsService.getCatalogsByStatus({ status, xDbCatalog }) as TData, ...options });
export const useCatalogsServiceGetCatalogsByDescription = <TData = Common.CatalogsServiceGetCatalogsByDescriptionDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ description, xDbCatalog }: {
    description: string;
    xDbCatalog: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn" | "initialData">) => useQuery<TData, TError>({ queryKey: [Common.useCatalogsServiceGetCatalogsByDescriptionKey, ...(queryKey ?? [{ description, xDbCatalog }])], queryFn: () => CatalogsService.getCatalogsByDescription({ description, xDbCatalog }) as TData, ...options });
export const useCatalogsServiceGetCatalogsGroupByColumn = <TData = Common.CatalogsServiceGetCatalogsGroupByColumnDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ column, xDbCatalog }: {
    column: string;
    xDbCatalog: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn" | "initialData">) => useQuery<TData, TError>({ queryKey: [Common.useCatalogsServiceGetCatalogsGroupByColumnKey, ...(queryKey ?? [{ column, xDbCatalog }])], queryFn: () => CatalogsService.getCatalogsGroupByColumn({ column, xDbCatalog }) as TData, ...options });
export const useCatalogsServiceGetCatalogs = <TData = Common.CatalogsServiceGetCatalogsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ type, xDbCatalog }: {
    type: string;
    xDbCatalog: string;
}, queryKey?: TQueryKey, options?: Omit<UseQueryOptions<TData, TError>, "queryKey" | "queryFn" | "initialData">) => useQuery<TData, TError>({ queryKey: [Common.useCatalogsServiceGetCatalogsKey, ...(queryKey ?? [{ type, xDbCatalog }])], queryFn: () => CatalogsService.getCatalogs({ type, xDbCatalog }) as TData, ...options });
export const useCatalogsServicePostCatalogs = <TData = Common.CatalogsServicePostCatalogsMutationResult, TError = unknown, TContext = unknown>(options?: Omit<UseMutationOptions<TData, TError, {
    requestBody?: Catalogs;
    xDbCatalog: string;
}, TContext>, "mutationFn">) => useMutation<TData, TError, {
    requestBody?: Catalogs;
    xDbCatalog: string;
}, TContext>({ mutationFn: ({ requestBody, xDbCatalog }) => CatalogsService.postCatalogs({ requestBody, xDbCatalog }) as unknown as Promise<TData>, ...options });
@bryanjtc bryanjtc changed the title V1 ommits put, and delete requests V1 ommits put and delete requests Apr 17, 2024
@DarkC0der11
Copy link

Same problem here.

@seriouslag
Copy link
Collaborator

@bryanjtc, @DarkC0der11, sorry you all are having issues.
Thank you for providing a spec file.

Did the hooks generate before v1.0.0?

Currently, the generator only handles GET and POST, but we should be able to support the other methods.

@bryanjtc
Copy link
Contributor Author

@bryanjtc, @DarkC0der11, sorry you all are having issues.
Thank you for providing a spec file.

Did the hooks generate before v1.0.0?

Currently, the generator only handles GET and POST, but we should be able to support the other methods.

Yes before v1.0.0 get, post, delete and put generated.

@seriouslag
Copy link
Collaborator

Opened a PR to generate mutations for PUT, PATCH, and DELETE requests. #74

@seriouslag seriouslag added the bug Something isn't working label Apr 20, 2024
@seriouslag
Copy link
Collaborator

seriouslag commented Apr 20, 2024

Released a test version with this patch under: @seriouslag/openapi-react-query-codegen@next
Until we merge the patches into this repo 😀

@7nohe 7nohe closed this as completed in #74 Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants