Skip to content

feat(huma): the rules of valigo in the OpenAPI document - #71

Merged
Insei merged 2 commits into
mainfrom
feat/huma-openapi
Oct 19, 2026
Merged

Insei merged 2 commits into
mainfrom
feat/huma-openapi

Conversation

@Insei

@Insei Insei commented Oct 19, 2026

Copy link
Copy Markdown
Owner

vhuma.OpenAPI(api, v) returns the OpenAPI document of huma with the constraints of #70 in the schemas of the request bodies and their nested structs, so the clients and SDK generators see maxLength, format, enum, items, the required properties of the rules of valigo.

  • The document is a JSON copy: the schemas of huma, which huma validates the requests by, are not changed — no duplicate untranslated errors of huma, the rules stay in Resolve.
  • A keyword with another value than the one of the tags of huma (two maxLength, two pattern) goes to allOf; an equal one is kept once; Required adds omitempty fields to required without repeats.
  • Embedded structs are flattened like huma does, json:"-" and hidden fields are skipped; the parameters keep the schemas of huma (an operation doesn't know its input type).

Docs: the page Integrations → JSON Schema (the table of the keywords, why the description is never stricter than the rule, Schema of own conversions) and the section of huma with a checked program. 100% coverage.

Insei added 2 commits October 19, 2026 11:22
OpenAPI returns the OpenAPI document of the api with the constraints of
the validator in the schemas of the request bodies and their nested
structs: maxLength, format, enum, items, the required properties... A
keyword with another value than the one of huma goes to allOf. The
schemas of huma, which it validates the requests by, are not changed.
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark diff: d14ecaf → 38863db (10 runs)

goos: linux
goarch: amd64
pkg: github.com/insei/valigo
cpu: Intel(R) Xeon(R) Platinum 8370C CPU @ 2.80GHz
           │  base.txt   │              head.txt              │
           │   sec/op    │   sec/op     vs base               │
Validate-4   135.1n ± 0%   137.8n ± 2%  +2.00% (p=0.000 n=10)

           │  base.txt  │            head.txt            │
           │    B/op    │    B/op     vs base            │
Validate-4   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

           │  base.txt  │            head.txt            │
           │ allocs/op  │ allocs/op   vs base            │
Validate-4   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d14ecaf) to head (dfcc7d2).

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #71   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           36        37    +1     
  Lines         1189      1250   +61     
=========================================
+ Hits          1189      1250   +61     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Insei
Insei merged commit a96d717 into main Oct 19, 2026
6 checks passed
@Insei
Insei deleted the feat/huma-openapi branch October 19, 2026 08:24
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.

2 participants