Skip to content

Duplicated class name #287

Description

@trivialkettle

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions