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

Unqualified name clash #309

Open
juneidy opened this issue Dec 14, 2023 · 1 comment
Open

Unqualified name clash #309

juneidy opened this issue Dec 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@juneidy
Copy link
Contributor

juneidy commented Dec 14, 2023

An example schema:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Blah",
    "version": "1"
  },
  "paths": {},
  "components": {
    "schemas": {
      "Clazz": {
        "type": "object",
        "properties": {
          "parentProps": {
            "type": "string"
          }
        }
      },
      "Foo.Bar.Baz.Clazz": {
        "allOf": [{ "$ref": "#/components/schemas/Clazz" }, {
          "type": "object",
          "required": [
            "arrayProperty"
          ],
          "properties": {
            "refProperty": {
              "$ref": "#/components/schemas/Foo.Bar.Baz.Clazz"
            },
            "arrayProperty": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/Foo.Bar.Baz.Clazz"
              }
            },
            "objectProperty": {
              "type": "object",
              "required": [
                "nestedArray",
                "nestedRef"
              ],
              "properties": {
                "nestedArray": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Foo.Bar.Baz.Clazz"
                  }
                },
                "nestedRef": {
                  "$ref": "#/components/schemas/Foo.Bar.Baz.Clazz"
                }
              }
            }
          }
        }]
      }
    }
  }
}

Produces wrong typescript:

import { Clazz } from '../../../../models/clazz';
export type Clazz = Clazz & {
'refProperty'?: Clazz;
'arrayProperty': Array<Clazz>;
'objectProperty'?: {
'nestedArray': Array<Clazz>;
'nestedRef': Clazz;
};
};

I think the only way to do this is to always use qualified name, so it will look roughly like:

import { Clazz } from '../../../../models/clazz';
export type FooBarBazClazz = Clazz & {
'refProperty'?: FooBarBazClazz;
'arrayProperty': Array<FooBarBazClazz>;
'objectProperty'?: {
'nestedArray': Array<FooBarBazClazz>;
'nestedRef': FooBarBazClazz;
};
};

Thoughts?

@juneidy
Copy link
Contributor Author

juneidy commented Dec 19, 2023

FYI: I've made a workaround https://github.com/juneidy/ng-openapi-gen/tree/unqualified-bug

Let me know if there's any improvement you have in mind.

@luisfpg luisfpg added the bug Something isn't working label Sep 6, 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

No branches or pull requests

2 participants