Summary
dump_models in src/utils/models_dumper.py duplicates the OpenAPI schema-writing logic already implemented in dump_schema in src/utils/schema_dumper.py. Both functions:
- Build a schema via
pydantic.json_schema.models_json_schema with the same ref_template.
- Apply
recursive_update post-processing.
- Wrap the result in an identical OpenAPI 3.0 structure (
openapi, info, components.schemas, paths).
- Write the result to a file with the same
json.dump(..., indent=4) call.
The only real differences are the list of models passed in and the docstring.
Rationale
This is a DRY violation that increases maintenance burden — any future change to the OpenAPI wrapping logic (e.g., metadata, formatting, error handling) needs to be duplicated in two places.
Affected areas
src/utils/models_dumper.py (dump_models)
src/utils/schema_dumper.py (dump_schema)
Suggested change
Extract a shared private helper, e.g. _dump_openapi_schema(models: list, filename: str) -> None, that accepts the list of Pydantic models and the output filename, performs the schema generation/post-processing/wrapping/write, and have both dump_models and dump_schema call it with their respective model lists.
Acceptance criteria
References
Summary
dump_modelsinsrc/utils/models_dumper.pyduplicates the OpenAPI schema-writing logic already implemented indump_schemainsrc/utils/schema_dumper.py. Both functions:pydantic.json_schema.models_json_schemawith the sameref_template.recursive_updatepost-processing.openapi,info,components.schemas,paths).json.dump(..., indent=4)call.The only real differences are the list of models passed in and the docstring.
Rationale
This is a DRY violation that increases maintenance burden — any future change to the OpenAPI wrapping logic (e.g., metadata, formatting, error handling) needs to be duplicated in two places.
Affected areas
src/utils/models_dumper.py(dump_models)src/utils/schema_dumper.py(dump_schema)Suggested change
Extract a shared private helper, e.g.
_dump_openapi_schema(models: list, filename: str) -> None, that accepts the list of Pydantic models and the output filename, performs the schema generation/post-processing/wrapping/write, and have bothdump_modelsanddump_schemacall it with their respective model lists.Acceptance criteria
dump_modelsanddump_schema.tests/unit/utils/test_models_dumper.py) continue to pass.References