Skip to content

map System.Text.Json.Nodes types to OpenAPI schemas#8053

Merged
dani-garcia merged 1 commit into
mainfrom
fix/swagger-jsonnode-schema-mapping
Jul 24, 2026
Merged

map System.Text.Json.Nodes types to OpenAPI schemas#8053
dani-garcia merged 1 commit into
mainfrom
fix/swagger-jsonnode-schema-mapping

Conversation

@dani-garcia

Copy link
Copy Markdown
Member

🎟️ Tracking

📔 Objective

#7898 changed ConfigResponseModel.FeatureStates to IReadOnlyDictionary<string, JsonValue>. Swashbuckle doesn't special-case System.Text.Json.Nodes types, so it reflected over JsonValue's members and emitted a bogus JsonValue component (options/parent/root), which the SDK generator turned into a made-up type and broke the bindings.

This registers MapType mappings in the shared Swagger setup so these opaque types render as free-form schemas (matching the old object behavior), keeping JsonValue as the accurate model type and covering future uses across the Api and Identity specs.

📸 Screenshots

Swashbuckle reflected over the members of JsonNode/JsonValue and emitted a
bogus, self-referential "JsonValue" component (options/parent/root). The SDK
code generator then materialized that as a made-up type, breaking the generated
bindings for ConfigResponseModel.FeatureStates.

Register MapType mappings so these opaque JSON types render as free-form schemas,
restoring the free-form 'object' behavior these bindings previously relied on.
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed the addition of four MapType mappings in SwaggerGenOptionsExt.InitializeSwaggerFilters that render System.Text.Json.Nodes types (JsonNode, JsonValue, JsonObject, JsonArray) as free-form OpenAPI schemas. The change correctly targets the root cause described in the objective: Swashbuckle reflecting over JsonValue members and emitting a bogus named component that broke the SDK bindings. The API usage (OpenApiSchema, JsonSchemaType.Object/Array) is consistent with the Microsoft.OpenApi v2 conventions already used by the sibling schema filters in the same directory.

Code Review Details

No findings. The mappings match the prior free-form object behavior, JsonObject/JsonArray are typed appropriately, and the explanatory comment documents the rationale. No security, correctness, breaking-change, or performance concerns.

@dani-garcia dani-garcia added the t:misc Change Type - ¯\_(ツ)_/¯ Prefer using other type labels label Jul 24, 2026
@dani-garcia
dani-garcia requested review from a team and dereknance July 24, 2026 11:42
@dani-garcia
dani-garcia merged commit e8917a8 into main Jul 24, 2026
47 of 49 checks passed
@dani-garcia
dani-garcia deleted the fix/swagger-jsonnode-schema-mapping branch July 24, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t:misc Change Type - ¯\_(ツ)_/¯ Prefer using other type labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants