openapi2aspida icon indicating copy to clipboard operation
openapi2aspida copied to clipboard

Bug: Issues Generating API Client from Dynamic `.json`-Included Paths with openapi2aspida

Open KiichiSugihara opened this issue 1 year ago • 0 comments

Description

When using path names that include .json in the OpenAPI definition, attempting to generate an API client with openapi2aspida results in a file name pattern matching error. This issue specifically occurs with parameterized paths (e.g., /category/{id}.json), not with static paths (for example, /new.json). Removing .json from the path resolves the issue, enabling successful API client generation

Environment

  • Package version: v0.23.2
  • OS:
    • [ ] Linux
    • [ ] Windows
    • [x] macOS
  • Node.js version: v20.9.0
  • npm version: 10.1.0

Additional context

Specifying a path that includes .json in the OpenAPI definition leads to the following error:

Error: aspida ERROR '_'id}.jso'' does not match '/^_[a-zA-Z][a-zA-Z0-9_]*(@number|@string)?((\.|%[0-9a-fA-F]{2})[a-zA-Z0-9]+)?$/'.

In current Rails applications, it is a common practice to maintain existing routes and use the .json extension to distinguish between HTML and JSON responses. This issue is particularly pronounced in API designs that include dynamic .json paths and the inability to generate API clients using openapi2aspida for these paths could significantly impact practical development workflows. Addressing this issue is crucial for maintaining compatibility with existing Rails conventions and supporting a wider range of API design practices.

KiichiSugihara avatar Feb 15 '24 01:02 KiichiSugihara