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

Duplicate endpoints create conflicting data types #154

Closed
CHE1RON opened this issue Sep 30, 2024 · 3 comments
Closed

Duplicate endpoints create conflicting data types #154

CHE1RON opened this issue Sep 30, 2024 · 3 comments

Comments

@CHE1RON
Copy link

CHE1RON commented Sep 30, 2024

Describe the bug
When having endpoints of the same name, eg tags/{tag}/export and labels/{label}/export, only one data type is generated (here ExportData) for all services, which is correct for the first, but wrong for all subsequent services.

To Reproduce

  1. Create API with endpoints tags/{tag}/export and labels/{label}/export
  2. Run script
  3. Inspect type errors in services.gen.ts

OpenAPI spec file
routes.json

Expected behavior
Data types free of conflicts, eg ExportData, ExportData1, etc

Screenshots
If applicable, add screenshots or logs to help explain your problem.

  • OS: macOS v14.4
  • Version 1.6.3
@7nohe
Copy link
Owner

7nohe commented Oct 14, 2024

services.gen.ts is a file generated on the @hey-api/openapi-ts side, so it falls outside the scope of this library.
This issue can likely be avoided by using operationId.

@7nohe 7nohe closed this as completed Oct 14, 2024
@CHE1RON
Copy link
Author

CHE1RON commented Oct 14, 2024

@7nohe Thanks for letting me know 🙏

I guess I'll open an issue upstream then. How exactly does operationId work? From the docs it seems to be a flag, but its default is true .. ?

@7nohe
Copy link
Owner

7nohe commented Oct 14, 2024

@CHE1RON
Yes, the default is true. Therefore, all you need to do is make each operationId unique.

"paths": {
    "/api/v1/boards/export": {
      "get": {
        "tags": ["boards"],
        "summary": "Returns an export of a collection of boards.",
        "operationId": "boards-export",

   "/api/v1/documents/{file}/export": {
      "get": {
        "tags": ["documents"],
        "summary": "Exports the document as a PDF with annotations included.",
        "operationId": "documents-export",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants