rametta / rapini

:leafy_green: OpenAPI to React Query (or SWR) & Axios
Apache License 2.0
152 stars 18 forks source link

[Bug] OpenAPI Document version not supported #54

Closed 1saifj closed 2 months ago

1saifj commented 2 months ago

Describe the bug

The OpenAPI document provided in Swagger v2 format is not supported by the rapini command when attempting to generate a React Query v5 package. The command fails with an error stating that the OpenAPI document version is not supported.

To reproduce

Steps to reproduce the behavior:

  1. Place the swagger.json file with the content below in your project directory.
  2. Run the following command:
    
    npx rapini react-query v5 -p swagger.json
  3. Observe the output:
    Generating React Query v5 package using OpenAPI file swagger.json
    API name: Swagger Petstore, Version: 1.0.7
    Failed to parse API document. OpenAPI Document version not supported

Expected behavior The rapini command should support Swagger v2 (OpenAPI 2.0) documents and successfully generate the React Query v5 package.

Swagger v2 File: swagger.json

rametta commented 2 months ago

Hi @1saifj , thanks for opening the issue. We currently only support v3+ as seen here: https://github.com/rametta/rapini/blob/2378a4bbaa435ae85a6af3dd1b521f6b55d47729/src/react-query/generator.ts#L22-L26

But PR's are always appreciated if you would like to add support for v2 - otherwise it is not planned to be added anytime soon