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

Keep plural names for objects #41

Open
a1d4r opened this issue Nov 11, 2021 · 1 comment
Open

Keep plural names for objects #41

a1d4r opened this issue Nov 11, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@a1d4r
Copy link
Contributor

a1d4r commented Nov 11, 2021

Describe

Plural names of JSON objects are converted to singular nouns (e.g. details -> Detail, statistics -> Statistic). It is an expected behaviour for JSON arrays but not for objects.

Reproduce

Package version: v0.2.4

JSON data:
example.py

{
  "details": {
    "amount": 1,
    "description": "Lorem Ipsum"
  },
  "statistics": {
    "likes": 100,
    "comments": 200
  }
}

json2models -m Example example.json -f pydantic --max-strings-literals 1 > example.py

Desired result

class Example(BaseModel):
    details: 'Details'
    statistics: 'Statistics'


class Details(BaseModel):
    amount: int
    description: str


class Statistics(BaseModel):
    likes: int
    comments: int

Actual result

class Example(BaseModel):
    details: 'Detail'
    statistics: 'Statistic'


class Detail(BaseModel):
    amount: int
    description: str


class Statistic(BaseModel):
    likes: int
    comments: int
@a1d4r a1d4r added the enhancement New feature or request label Nov 11, 2021
@bogdandm
Copy link
Owner

Thank you for reporting. I agree that it should work as you described. Unfortunately its requires some untrvial changes to the core logic of generator and currently I don't have time to impelement it.

@bogdandm bogdandm added the help wanted Extra attention is needed label Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants