Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

ilovelinux/datamodel-code-generator-issue-2460

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fixed with PR #2461

datamodel-code-generator reproducible example for issue #2460

Inputs Outputs
inputs/aaaschema.json outputs/aaaschema.py
inputs/commons.json outputs/commons.py
inputs/bug.json outputs/bug.py

Debug logs HERE

Description of the problem

  • I define allowedAnimals in aaaschema.json as an array of objects
  • I generate the code. A RootModel is generated and it works.
  • I define allowedAnimals as object with additionalProperties: false in bug.json
  • I generate the code. The model of the first schema has been edited and now the RootModel has extra: forbid (which is not valid)
  • I rename allowedAnimals in bug.json with a different name
  • Now the generated code of aaaschema.json is correct again.

Goal

We don't want bug.json definitions to interfere with the generation of the models for aaaschema.json

Issue

Somehow, allowedAnimals definition in bug.json add extra: false to allowedAnimals RootModel generated for aaaschema.json which result in an:

  • Incorrect behavior
  • Invalid output

Generate models

$ pip install -r requirements.txt
$ datamodel-codegen

About

datamodel-code-generator reproducible example for issue #2330

Resources

Stars

Watchers

Forks

Languages