Code Monkey home page Code Monkey logo

jsontopydantic's People

Contributors

brokenloop avatar matthieudesprez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jsontopydantic's Issues

what's the size/nest level limitation of the tool?

I tried loading large json(via webpage) with nested elements and seems it stuck "loading..." and doesn't output the pydantic class .

Json:

{"digital.ms.price.":{"popRelationship":null,"role":"Price","taxIncluded":"Included","priceCharacteristic":null,"recurringChargePeriodType":null,"description":{"en-US":"u 8GBprice"},"type":"TablePrice","recurringChargePeriodLength":null,"priceEvent":null,"priceRecord":[{"priority":0,"priceRecordId":"c9902af4-53ff-438e-aeb8-47c90c1381fc","price":[{"priceReduction":null,"id":"4093ddc4-7bd9-434f-996f-adf59f86d61b","validFor":{"endDateTime":null,"startDateTime":"2018-11-21T00:00:00Z"},"taxIncludedAmount":{"value":"26700.0","unit":"IDR"},"percentage":null,"dutyFreeAmount":null}],"parameter":{"SalesChannel":{"name":"SalesChannel","valueTo":null,"unitOfMeasure":null,"value":"Any_Value","valueFrom":null},"TIERED_PRICING_COUNTER":{"name":"TIERED_PRICING_COUNTER","valueTo":null,"unitOfMeasure":null,"value":"0","valueFrom":null}}},{"priority":0,"priceRecordId":"f177993b-2275-4d41-9f92-7a0aa453d12c","price":[{"priceReduction":null,"id":"046fca9e-dbdb-4480-8d7b-ea39473715af","validFor":{"endDateTime":null,"startDateTime":"2018-11-21T00:00:00Z"},"taxIncludedAmount":{"value":"26700.0","unit":"IDR"},"percentage":null,"dutyFreeAmount":null}],"parameter":{"SalesChannel":{"name":"SalesChannel","valueTo":null,"unitOfMeasure":null,"value":"Any_Value","valueFrom":null},"TIERED_PRICING_COUNTER":{"name":"TIERED_PRICING_COUNTER","valueTo":null,"unitOfMeasure":null,"value":"999","valueFrom":null}}}],"installments":null,"price":[],"priceCategory":null,"immediatePayOption":{"payOption":"Optional","payImmediately":null,"payAmount":null,"minPayAmount":null},"currency":"IDR","id":"00be0e7f-51d3-4793-bc9c-fbdf036dab85","overrideOption":[{"allowWaive":true,"extension":null,"userRole":null,"maxIncreaseValue":{"amount":{"value":"99999","unit":"IDR"},"taxIncludedAmount":null,"percentage":null,"dutyFreeAmount":null},"allowOverride":true,"maxDecreaseValue":{"amount":null,"taxIncludedAmount":null,"percentage":100,"dutyFreeAmount":null}}],"priceAlterationCategory":null,"key":{"sequence":"00be0e7f-51d3-4793-bc9c-fbdf036dab85","keyString":"2ed2f2a1-2e04-4870-bc4b-8479a7f87e7c_00be0e7f-51d3-4793-bc9c-fbdf036dab85","entityType":"2ed2f2a1-2e04-4870-bc4b-8479a7f87e7c","onlySequence":false},"policy":{"name":[{"locale":"en-US","value":"Tiered_pricing_policy_for_RC"}],"id":"ed536645-d038-4d55-a771-2e72b7e9789f"},"owner":"D1","unitOfMeasure":null,"validFor":{"endDateTime":null,"startDateTime":"2018-11-21T00:00:00Z"},"priceDifference":null,"priceType":"OC","isVersion":null,"effectivenessPolicy":null,"priceParameterAdditionalData":null,"keyPathMap":{"2ed2f2a1-2e04-4870-bc4b-8479a7f87e7c_00be0e7f-51d3-4793-bc9c-fbdf036dab85":""},"name":{"en-US":"23rad price"}}}

```

Missing license

Hi! I think this project & website are great, but I wasn't able to use them because there's no license. I ended up using datamodel-code-generator directly, with some additional effort, since I wasn't sure what the terms of use were from outputs from your code or website. I would love to use this in the future!

Nested fields not marked as Optional

When specify every field as Optional is checked only the top level fields are makred as optional, any nested classes are not marked as optional.

Input:

{
	"foo": 5, 
	"barBaz": {
	    "nested":"hello"
	}
}

Output

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel


class BarBaz(BaseModel):
    nested: str


class Model(BaseModel):
    foo: Optional[int] = None
    barBaz: Optional[BarBaz] = None

Thanks for the useful tool!

Add option to create example

Example data is already being introduced on the base json provided. The fields could be used to provide an example to the pydantic field, which usually helps on the implementation.

I'm willing to contribute the change

collaboration issues

Hi,

First of all, thanks for creating and deploying this project.

I'd like to contribute with a new feature to take advantage of Optional + snake_cased handling from datamodel-code-generator as I used it a lot locally, but I don't seem to have the right access to push anything to this repository.

Is there a specific setting that prevents me to do so ?

Specific json conversion

The tool currently converts this json

{
  "accounts": {
    "98230": {
      "name": "BHN1",
      "status": "ACTIVE"
    },
    "57150": {
      "name": "Sec",
      "status": "ACTIVE"
    }
  }
}

to something along the lines of

class Accounts(BaseModel):
    field_98230: Field98230 = Field(..., alias='98230')
    field_57150: Field57150 = Field(..., alias='57150')


class Model(BaseModel):
    accounts: Accounts

This might be more useful result rather than having a field for each value

class Model2(BaseModel):
    accounts: Optional[OrderedDict[str, ModelItem]]

generator.py - TypeError: __init__() got an unexpected keyword argument 'text'

Python 3.8.8,
I'm trying to run the generator.py by itself and getting error:


root@a21f0d01a432:/webserver/myTest# python3 generator.py
Traceback (most recent call last):
  File "gen.py", line 30, in <module>
    result = translate(data)
  File "gen.py", line 18, in translate
    parser = JsonSchemaParser(
TypeError: __init__() got an unexpected keyword argument 'text'

can you tell what could be the reason?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.