Skip to content

feat: an opt-in setting of AddTypeKit writes every value object in place - #136

Merged
CaffeinatedCoder merged 1 commit into
release/2.3.0from
feat/openapi-inline-value-objects
Oct 29, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/2.3.0from
feat/openapi-inline-value-objects

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #83

Problem

With AddTypeKit(), a value object in a body keeps a component named after it. Some clients do better with plain types: a generator that makes a class per component gives a CustomerId wrapper where the application wanted a string, and under OpenAPI 2.0 a nullable property of a component loses its type (KB-026). Inlining took a host's own CreateSchemaReferenceId set after AddTypeKit(), reflecting over a CompilerServices attribute, which also replaced TypeKit's naming and decision 55's check for closed sets.

Change

  • AddTypeKit(typeKit => typeKit.InlineValueObjects = true): a new overload taking Action<TypeKitOpenApiOptions> (new public class, one property, off by default). AddTypeKit() now calls it with no setting.
  • ValueObjectSchemaReferenceIds: with the setting, a value object or its Nullable<T> gets null before the host's delegate is asked, so every position takes the existing inline path. Closed sets and wrapped enums keep their components and their claims.
  • Decision 115 (design/adr/0115-value-objects-can-be-inlined-everywhere.md, index row, design/openapi.md): the setting, why value objects only, and how it sits with decisions 55 (an inlined value object claims no name; closed sets still refused) and 106 (nothing left to decide: no component is shared between JSON positions and parameters).
  • Docs: docs/aspnet-core.md "Describe value objects as plain types" with a compiled sample and a test that holds the JSON it shows; the package README's predicate gives way to the setting (its sample region removed); changelog line under 2.3.0.
  • Oracles: five claims (C27-*), SchemaTests registered as a differential oracle with the seed inline-value-objects-ignored.patch, axes.md row for where value objects are described.

Tests

  • SchemaTests runs under both settings in OpenAPI 3.1, 3.0 and 2.0; inlined, also over the nullable properties, the containers and nested containers, whose controls were added to ControlDocument, and a dictionary keyed by a value object (CountsById, both settings). OpenApiJson.Components reads 2.0's definitions.
  • NullablePositionTests' inline-value-objects mode is the setting: every position (body, query, header, form, route, response, elements, values, query/header items, polymorphic) × 3.1/3.0/2.0 × enums by number/name × MVC/minimal.
  • InlineValueObjectsSettingTests: no value-object component in any version (with the default document as control), the default document byte for byte with no setting and with the setting off, a later plain AddTypeKit() keeps them inlined, the host's names for other types, decision 55's claims, a null configuration.
  • Seeded: the setting ignored → 169 of 522 fail (SchemaTests 92, NullablePositionTests 72, the setting tests 5); oracles seeds inline-value-objects-ignored → CAUGHT, 92 of 164. The setting on by default → 70 of 174 fail (every component row and the default-document test).
  • Full solution locally: 18,613 passed, 1 failed (a relative link in the package README, fixed and re-run green).

🤖 Generated with Claude Code

AddTypeKit(typeKit => typeKit.InlineValueObjects = true) gives no value object a
component: the reference-id wrapper answers null for a value object, or its
Nullable<T>, before the host's delegate, so every position takes the inline path.
Closed sets and wrapped enums keep their components and their claims (decision 55);
without the setting the document is unchanged. Decision 115 records it.

SchemaTests runs under both settings in 3.1, 3.0 and 2.0, inlined over the nullable
properties and the containers too, with controls added for the ones that had none,
and is registered as an oracle with the seed inline-value-objects-ignored.
NullablePositionTests' inline-value-objects mode is now the setting. The variant
class is where value objects are described (components, the setting, a host's own
null) by the version; a described type's parameter under the setting is listed in
axes.md as a pair no test varies yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 2.3.0 milestone Oct 29, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request package/aspnetcore Affects CodoMetis.TypeKit.AspNetCore labels Oct 29, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit a898b93 into release/2.3.0 Oct 29, 2026
8 of 9 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/openapi-inline-value-objects branch October 29, 2026 13:21
CaffeinatedCoder added a commit that referenced this pull request Oct 29, 2026
#136 took decision 0115, so the docs site's record is renumbered to 0116:
the file, its heading, its index row and every link to it. Both changelog
lines and both index rows kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request package/aspnetcore Affects CodoMetis.TypeKit.AspNetCore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant