Comments (1)
I encountered the same issue, but found out that setting the additionalProperties
property to false
in the JSON schema definitions results in a generated model with the extra
attribute in the model_config
set to "forbid":
model_config = ConfigDict(
extra='forbid',
)
from datamodel-code-generator.
Related Issues (20)
- (🎁) Use `ruff format` instead of `black` + `isort`
- Incompatible Default Value When Field is Generated as RootModel
- Sometimes using serialization_alias would be better than using alias; this should be switchable
- Model class names are missing the last letter in models generated from 2020-12 JSON schema specification HOT 1
- datamodel-codegen fails with OpenAI OpenAPI spec
- Broken Import Statement: inheriting schemas named with "dot" notation (ie: `$ref: '#/components/schemas/v0.animal`) HOT 1
- [BUG]: All of the fields have a None default
- workaround: better class names
- [one|any|all]Of+required schema rules produce numerous near-identical models which are then quite hard to differentiate
- Add `model_config = ConfigDict(use_attribute_docstrings=True)` when the command option `--use-field-description` is used HOT 1
- circular jsonschema with parent produces invalid pydantic model file
- Relative paths in url '$ref's are added to local file path instead of the url.
- pyproject.toml detection fails in subdirectories when the file has no `[tool.black]` section since black 24.2
- Valid JSON Schema results in error due to `additionalProperties` set to `false`
- Prefix child model names with name of parent to avoid name collision
- Support `webhooks` in `--openapi-scope`
- The following constraints cannot be applied to list[str]: 'pattern'
- AttributeError: 'NoneType' object has no attribute 'is_list'
- `required` fields declared in an `allof` are missing in the generated code
- Option `capitalize-enum-members` in `pyproject.toml` is ignored
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datamodel-code-generator.