fix: fix missing object in tags - #11
Conversation
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | Sep 16, 2026 5:52p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
🟡 Changes recommended
The structured-example decoder still accepts certain trailing JSON garbage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes swaggertype:"object" generation and improves structured example decoding and JSON/YAML escaping.
Changes:
- Adds recursive object and array
swaggertypeparsing. - Preserves structured examples and large numbers.
- Aligns JSON/YAML escaping and expands test coverage.
File summaries
| File | Changes and review notes |
|---|---|
testdata/sample.go |
Adds a json.RawMessage object fixture. |
gen/yaml.go |
Escapes YAML-invalid control characters and shared entities. |
gen/schema.go |
Implements recursive swaggertype parsing. |
gen/internal_test.go |
Adds unit coverage for coercion and encoding behavior. |
gen/gen_test.go |
Adds integration coverage for generated object schemas. |
gen/emit.go |
Adds shared JSON encoding. Nit (1 vote): the helper comment reverses the documented default behavior. |
gen/constrain.go |
Decodes structured examples and defaults. Moderate issue (3 votes): trailing JSON garbage with stray closing delimiters can be accepted. |
Review details
Suppressed comments (1)
gen/emit.go:96
- This comment reverses the behavior being documented: the default
json.MarshalIndentHTML-escapes&as\u0026, it does not write the literal&. As written, it can mislead callers about why this helper changes the JSON encoding policy.
// json.MarshalIndent would write "a=1&b=2"). A consumer that inlines
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
implement [ENG-9771]
504a6e1 to
8b50619
Compare
There was a problem hiding this comment.
🟢 Approval recommended
Only a non-blocking documentation nit remains.
Review details
Suppressed comments (1)
gen/emit.go:96
- The
encoding/jsondefault used byjson.MarshalIndentHTML-escapes&as\u0026, so this example currently describes the opposite of the behavior being replaced. Please correct the comment to show the escaped form (for example,"a=1\\u0026b=2") so callers are not misled about the compatibility change.
// json.MarshalIndent would write "a=1&b=2"). A consumer that inlines
- Files reviewed: 7/7 changed files
- Comments generated: 0 new
- Review effort level: Lite
implement ENG-9771
Pull request
What this PR does
Fixes
swaggertype:"object"being emitted astype: string, and tightens the related example and text-encoding paths found while verifying the fix.swaggertype tags (
gen/schema.go)objectis now accepted, bare or with a value type, sojson.RawMessagefields tagged
swaggertype:"object"emittype: object.object,<type>is a typed map,array,array,integerkeeps both dimensions, unknown element names degradeto string instead of an empty type, and whitespace after the comma is
tolerated.
Examples on object and array fields (
gen/constrain.go)example/defaulton an object field decodes to an objectinstead of a quoted string.
json.Number, so large integer ids do not round.null, trailing garbage, and non-JSON text stay plain strings.Text encoding (
gen/yaml.go,gen/emit.go)&,<,>are written literally in both YAML and JSON, through oneshared encoder helper, so the two formats no longer diverge.
reject raw.
Verification
go test -race ./...,go vet, andgolangci-lintare clean.stringtoobjectfix in themis.oasparitypasses, every YAML file issemantically equal to its JSON twin, and redocly validates all six.
Effect on annotations and output
How it was tested
make testpassesmake lintpassesmake parityrun (if output-affecting) — repo and result:Known gaps or follow-ups