Datamodel-code-generator: JSON key error

Created on 5 Apr 2020  路  4Comments  路  Source: koxudaxi/datamodel-code-generator

Describe the bug
I want to create pydantic models for the Spotify api and tried to parse an example response (see here).

  • datamode-codegen 0.4.4
  • python 3.8

To Reproduce

Download the gist, install datamodel-codegen and run the following command.

The command I am using to generate the the models is

datamodel-codegen --input-file-type jsonschema --input api_response.json --out output.py

Screenshots

image

bug

Most helpful comment

Tank you very much :D
I just confirmed that it is working now.

All 4 comments

@HuiiBuh

Thank you for creating this issue.

I found about Spotify's json data.
https://labs.spotify.com/2015/03/09/understanding-spotify-web-api/

This Json data is Json format which isn't Json Schema
This code generator supports Json Schema or OpenAPI.

About Json Schema
https://json-schema.org/

I totally missed that.
After I converted the json data to a json scheme and this time I get another exception.
(I edited the gist...)

image

@HuiiBuh

I have fixed the bug and released new version as 0.4.5

Tank you very much :D
I just confirmed that it is working now.

Was this page helpful?
0 / 5 - 0 ratings