deepObject: bracket-indexed arrays and nested objects - #111
Open
tanmaykm wants to merge 1 commit into
Open
Conversation
Restore the 0.2 behaviour for deepObject query parameters whose values are arrays or nested objects, using the bracket convention that qs, Rack and PHP produce (`filters[0][field]=v`, `sorts[0]=a&sorts[1]=b`, `name[]=v`). - planning: accept array schemas under deepObject at strict; only scalar schemas remain an error (strict) / warning (permissive). - runtime client encoder: flatten nested dicts/vectors recursively into indexed bracket paths instead of throwing or emitting `name[]`. The multipart deepObject encoder shares the helper. - server decoder: parse full bracket paths (percent-encoded brackets and `[]` appends included) into a tree, then rebuild it in the shape the parameter schema declares before validation: integer keys become array indices only where the schema expects an array, leaves stay strings where the schema says string, and $ref/allOf/oneOf/anyOf are followed. - schema engine: add non-throwing `trysubschema`. - docs: describe the extension; boundary page now lists only scalar deepObject as a permissive case. - version 1.1.0.
tanmaykm
marked this pull request as draft
September 5, 2026 19:03
tanmaykm
marked this pull request as ready for review
September 5, 2026 19:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #110.
Summary
deepObjectquery parameters with array schemas or nested object/array values worked in 0.2 (added in #78) but not in 1.0.0: strict rejected the schema, permissive planned it and then failed every request, and the client encoder threw on nested values. This restores end-to-end support using the bracket convention thatqs, Rack and PHP produce, as a documented extension accepted at strict.Changes
src/planning.jl): array schemas underdeepObjectplan at strict without diagnostics. Only scalar schemas still emitinvalid_deep_object_schema(error at strict, warning at permissive).src/runtime.jl): nested dicts and vectors flatten recursively into indexed bracket paths. Arrays now encode asname[0]=…rather thanname[]=…, matching the 0.2 encoder and theqsdefault. The multipart deepObject encoder shares the helper.src/servergen.jl+src/runtime.jl): full bracket paths (including percent-encoded brackets andname[]appends) build a tree, and a schema-guided pass rebuilds it in the declared shape before validation. Integer keys become array indices only where the schema expects an array, so anadditionalPropertiesobject keeps"0"as a string key. Leaves stay text where the schema saysstring, sosorts[0]=2024is no longer read as an integer.$ref,allOf,oneOfandanyOfare followed.trysubschemaaccessor.deepObjectas a permissive case.Decisions worth a look
expand[0]=a&expand[1]=b) instead ofexpand[]=a&expand[]=b. The server accepts both forms; this is a visible client wire change from 1.0.0.Verification
filters[0][field]=…pairs.qswire format,[]appends, encoded brackets, sparse indices, the array-vs-object-key decision, string leaves, and 400s for invalid shapes. Julia 1.10 was not available locally.OPENAPI_CORPUS_TESTS=smallpasses. Docs build passes and the new cross-reference resolves.--trim=safeworkload still passes. Note that the request/response runtime paths (query encoding, JSON decode, schema validation) were not trim-safe before this change and are not made so here; a widened trim workload fails the same way before and after.