jsonschema-gentypes icon indicating copy to clipboard operation
jsonschema-gentypes copied to clipboard

Preserving case when generating $ref classes

Open eupharis opened this issue 1 year ago • 5 comments

Using Python 3.10.12 and version jsonschema-gentypes 2.4.0

So for this schema:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "definitions": {
    "SubresourceUris": {
      "type": "object",
      "properties": {
        "feedback": {
          "type": "string"
        }
      },
      "required": ["feedback"],
      "title": "SubresourceUris"
    }
  },
  "type": "object",
  "properties": {
    "subresource_uris": {
      "$ref": "#/definitions/SubresourceUris"
    }
  },
  "required": [
    "subresource_uris"
  ],
  "title": "ResponseType"
}

when I run:

from jsonschema_gentypes.cli import process_config


config = {
    "python_version": None,
    "generate": [
      {
            "source": "./input.json",
            "destination": "./output.py",
        }
    ],
}
process_config(config)  # type: ignore

I get back the following:

from typing import TypedDict
from typing_extensions import Required


class Responsetype(TypedDict, total=False):
    """ ResponseType. """

    subresource_uris: Required["Subresourceuris"]
    """
    SubresourceUris.

    Required property
    """



class Subresourceuris(TypedDict, total=False):
    """ SubresourceUris. """

    feedback: Required[str]
    """ Required property """

Is there any way to have the output match the case of the input, and have the class be named SubresourceUris instead?

Love the library by the way! It's very nice.

eupharis avatar Jan 29 '24 20:01 eupharis