Skip to content

Absolute paths are generated? #85

@AnderssonPeter

Description

@AnderssonPeter

Describe the bug
When i generate my client code, absolute paths are used instead of relative.

Example of output

export const useLocalizationServiceGetTranslationTexts = <TData = Common.LocalizationServiceGetTranslationTextsDefaultResponse, TError = unknown, TQueryKey extends Array<unknown> = unknown[]>({ language, module }: {
    language: import("C:/Projekt/test/test_3.0/Frontend/src/openapi/requests/models").Language;
    module: import("C:/Projekt/test/test_3.0/Frontend/src/openapi/requests/models").Module;
}
  • OS: Windows 11 22H2
  • Version v1.1.0

Activity

changed the title [-]Static paths are generated?[/-] [+]Absolute paths are generated?[/+] on Apr 22, 2024
AnderssonPeter

AnderssonPeter commented on Apr 22, 2024

@AnderssonPeter
Author

The wierd thing here is that both Language and Module are imported using a normal import further up in the file.
import { ...., Language, Module, .... } from "../requests/models";

All invalid imports have one thing in common, they are enums, generated using --enums typescript

seriouslag

seriouslag commented on Apr 22, 2024

@seriouslag
Collaborator

@AnderssonPeter, this is fixed in #84

AnderssonPeter

AnderssonPeter commented on Apr 22, 2024

@AnderssonPeter
Author

It's for both queries and suspense, I don't have access to the spec right now but will try to get you an example tomorrow.

self-assigned this
on Apr 22, 2024
added a commit that references this issue on Apr 23, 2024
751c6ed
AnderssonPeter

AnderssonPeter commented on Apr 23, 2024

@AnderssonPeter
Author

@seriouslag the following specification causes the issue:

{
  "openapi": "3.0.1",
  "info": {
    "title": "API",
    "version": "1.0"
  },
  "paths": {
    "/api/localization/module/{module}/{language}": {
      "get": {
        "tags": [
          "localization"
        ],
        "operationId": "GetTranslationTexts",
        "parameters": [
          {
            "name": "module",
            "in": "path",
            "required": true,
            "style": "simple",
            "schema": {
              "$ref": "#/components/schemas/Module"
            }
          },
          {
            "name": "language",
            "in": "path",
            "required": true,
            "style": "simple",
            "schema": {
              "$ref": "#/components/schemas/Language"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/LocalizationText"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Language": {
        "enum": [
          "Swedish",
          "English"
        ],
        "type": "string"
      },
      "LocalizationText": {
        "required": [
          "key",
          "text"
        ],
        "type": "object",
        "properties": {
          "key": {
            "$ref": "#/components/schemas/TranslationTextKey"
          },
          "text": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Module": {
        "enum": [
          "Global",
          "ResearchProjects"
        ],
        "type": "string"
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "TranslationTextKey": {
        "enum": [
          "Close",
          "Menu"
        ],
        "type": "string"
      },
      "ValidationProblemDetails": {
        "required": [
          "errors"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "additionalProperties": { }
      }
    }
  }
}
seriouslag

seriouslag commented on Apr 23, 2024

@seriouslag
Collaborator

This was fixed in 1.2.0

AnderssonPeter

AnderssonPeter commented on Apr 24, 2024

@AnderssonPeter
Author

@seriouslag I just tested it and it works as expected, thanks for the quick fix!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @AnderssonPeter@seriouslag

    Issue actions

      Absolute paths are generated? · Issue #85 · 7nohe/openapi-react-query-codegen