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

Duplicated class name #287

Open
trivialkettle opened this issue Apr 30, 2024 · 0 comments
Open

Duplicated class name #287

trivialkettle opened this issue Apr 30, 2024 · 0 comments

Comments

@trivialkettle
Copy link

Hi,
if, for example I have a schema that has a duplicated class name, whats the best way to handle this? Currently the class builder "fails" silenty.

E.g. I reference a schema from another schema that uses the same title v1/node/foo.

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://my-url/node/any.schema.json#",
    "oneOf": [
        {
            "$ref": "./foo.schema.json"
        },
        {
            "$ref": "my-second-url/node/foo.schema.json"
        }
    ]
}

I use build_classes(named_only=True).

I would be nice to get notified about this, maybe like this in build_classes:

 for uri, klass in six.iteritems(builder.resolved):
            title = getattr(klass, "__title__", None)
            if title is not None:
                transformed_title = name_transform(title)
                if transformed_title in classes:
                    print("warning")
                classes[transformed_title] = klass
            elif not named_only:
                transformed_name = name_transform(uri.split("/")[-1])
                if transformed_name in classes:
                    print("warning")
                classes[transformed_name] = klass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants