Skip to content

Fix/pydantic nf validation errors - #2

Merged
tempont merged 4 commits into
mainfrom
fix/pydantic-nf-validation-errors
Oct 6, 2026
Merged

tempont merged 4 commits into
mainfrom
fix/pydantic-nf-validation-errors

Conversation

@tempont

@tempont tempont commented Oct 6, 2026

Copy link
Copy Markdown
Owner

No description provided.

@tempont-bot

tempont-bot Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Mira PR Walkthrough

This PR fixes pydantic validation errors in the generated NF-e (notas fiscais) and NFC-e (notas fiscais consumidor) schemas by refining schema overrides in the code generator and updating the generated model files. It extends scripts/generate_models.py to apply additional manual overrides so regenerated models stay consistent, updates the generated schemas/contracts/aliases accordingly, and adds new unit tests plus a real-world API response fixture to cover invoice model parsing. Documentation, changelog, and a version bump round out the release.

Confidence: 4/5   ◉◉◉◉○   Safe to merge
  • The PR fixes pydantic validation issues in generated NF-e/NFC-e schemas with dedicated override support in the generator, solid test coverage (new unit tests and fixtures), and no apparent risk of breaking existing behavior.

Key files to review:

  • scripts/generate_models.py:332 — The required-writeOnly detector only scans a schema's own top-level properties/required; a writeOnly-required property introduced via inline allOf/items composition (no $ref) is silently missed, so the response projection would not relax it and generated response models would keep requiring the field — the same failure mode this PR fixes, without any test covering that shape.

16 files reviewed · 2 comments (💡 2 suggestions)


Comment @tempont-bot help to get the list of available commands and usage tips.

@tempont-bot tempont-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mira Review Summary

The review flags two gaps in scripts/generate_models.py. The main one, at line 332, is that the required-writeOnly detector only scans a schema's own top-level properties and required lists, so a writeOnly-required property introduced via inline allOf/items composition (with no $ref) is silently missed. Separately, the response projection at line 319 skips responses routed through components.requestBodies/responses.

Key Issues

Issue Location
🔴 The required-writeOnly detector only scans a schema's own top-level properties/required; a writeOnly-required property introduced via inline allOf/items composition (no $ref) is silently missed, so the response projection would not relax it and generated response models would keep requiring the field — the same failure mode this PR fixes, without any test covering that shape. scripts/generate_models.py:332

Comment thread scripts/generate_models.py
Comment thread scripts/generate_models.py Outdated
@tempont
tempont merged commit e6935c1 into main Oct 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant