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

[Request] ability to reverse --collapse-root-models collapse order #1418

Open
alita-moore opened this issue Jul 8, 2023 · 2 comments
Open

Comments

@alita-moore
Copy link

Is your feature request related to a problem? Please describe.
Currently, without --collapse-root-models, I get the following:

class ISectionBlockMetadata(BaseModel):
    __root__: FieldType2
class FieldType2(BaseModel):
    as_text: str = Field(..., alias='asText', title='asText')

with --collapse-root-models, I get this:

class FieldType2(BaseModel):
    as_text: str = Field(..., alias='asText', title='asText')

The problem is that I want the merged class to be called ISectionBlockMetadata

Describe the solution you'd like
I would like the ability to reverse which name is adopted for the merged class, for instance, in the above example I would I would expect the merged class to be

class ISectionBlockMetadata(BaseModel):
    as_text: str = Field(..., alias='asText', title='asText')

Describe alternatives you've considered
For my use case (typescript -> json schema -> pydantic), I've submitted a feature request to the typescript-json-schema library to add (if it doesn't already exist) the ability to transfer the name to the title within the json schema (details: YousefED/typescript-json-schema#554)

Additional context
N/A

@alita-moore
Copy link
Author

As an update, I have implemented a work around for typescript-json-schema, I think the ability to remove nested / duplicated structures will lessen the need for work on this tool.

@alita-moore
Copy link
Author

on a different note, when I do --reuse-model it would be nice to have the option to merge the naming / reference into a single one. i.e. currently I might have something like

class BoundingRegionSchema(BaseModel):
  ...etc

class BoundingRegion(BoundingRegionSchema):
  pass

But this makes for more confusing relationships, is there a way to collapse these references into BoundingRegionSchema?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant