Skip to content

chore(deps): bump Microsoft.OpenApi 1.6.28 → 3.5.1 (#67)#152

Merged
emilyoram merged 3 commits into
mainfrom
chore/refactor-openapi-3
May 5, 2026
Merged

chore(deps): bump Microsoft.OpenApi 1.6.28 → 3.5.1 (#67)#152
emilyoram merged 3 commits into
mainfrom
chore/refactor-openapi-3

Conversation

@jwulf

@jwulf jwulf commented May 1, 2026

Copy link
Copy Markdown
Member

Refactors CSharpClientGenerator onto the Microsoft.OpenApi 3.x model surface — the upgrade originally proposed in #45 that broke the build (#67).

Why now

Regression protection landed in #151. With public API surface, model serialization round-trips, enum wire contracts, and polymorphic dispatch all locked by 810 unit tests, the refactor becomes a mechanical exercise: keep the suite green and Generated/* byte-identical, and the change is provably non-regressive on the dimensions that matter to consumers.

Changes

All edits are confined to src/Camunda.Orchestration.Sdk.Generator/.

  • Drop Microsoft.OpenApi.Readers (folded into Microsoft.OpenApi 3.x).
  • Switch the reader to OpenApiModelFactory.LoadAsync.
  • Use IOpenApiSchema (the new model interface) where schemas are consumed from the document. The concrete OpenApiSchema is no longer the wire type for refs — referenced schemas flow through as a separate OpenApiSchemaReference class.
  • Replace schema.Reference != null with a GetRefId helper that pattern-matches on OpenApiSchemaReference.
  • Replace string Type checks ("string", "integer", …) with a SchemaTypeName helper that maps the new JsonSchemaType [Flags] enum back to the OpenAPI 3.0 type strings, masking out the JsonSchemaType.Null bit (set by the v3 reader for OpenAPI 3.0 nullable: true).
  • Replace OpenApiSchema.Nullable with an IsNullable helper that reads the JsonSchemaType.Null bit (3.1 nullability is type-array based).
  • Replace OpenApiString enum value casts with JsonNode reading.
  • Switch verb representation from the removed OperationType enum to System.Net.Http.HttpMethod (the v3 model uses HttpMethod as the PathItem.Operations dictionary key); the codegen string switch now matches on HttpMethod.Method.
  • Adjust Discriminator.Mapping value access — values are now OpenApiSchemaReference, not raw \$ref path strings.

Validation

  • bash scripts/build-local.sh — clean. Generated/* is byte-identical against the committed bundle on this branch (zero drift).
  • dotnet build --configuration Release — clean.
  • dotnet format --verify-no-changes — clean.
  • dotnet test810 / 810 pass on net8.0 and net10.0.

Because Generated/* is byte-identical, the public API, JSON wire format, polymorphic dispatch tables, and tenant-injection behaviour are provably unchanged.

Closes #67. Supersedes #45.

Refactors CSharpClientGenerator onto the v3.x model surface:

- Drop Microsoft.OpenApi.Readers (folded into Microsoft.OpenApi 3.x).
- Switch reader to OpenApiModelFactory.LoadAsync.
- Use IOpenApiSchema (the new model interface) where schemas are consumed
  from the document; concrete OpenApiSchema is no longer the wire type.
- Replace schema.Reference != null with a GetRefId helper. $refs are now
  modelled as a separate OpenApiSchemaReference class implementing
  IOpenApiSchema, not as a Reference property on every schema.
- Replace string Type checks ('string', 'integer', …) with a SchemaTypeName
  helper that maps the new JsonSchemaType [Flags] enum back to the legacy
  OpenAPI 3.0 type strings, masking out the JsonSchemaType.Null bit
  (which the v3 reader sets for OpenAPI 3.0 nullable: true).
- Replace OpenApiSchema.Nullable with an IsNullable helper that reads the
  JsonSchemaType.Null bit (OpenAPI 3.1 nullability is type-array based).
- Replace OpenApiString enum value casts with JsonNode reading.
- Switch verb representation from the removed OperationType enum to
  System.Net.Http.HttpMethod (the v3 model uses HttpMethod as the
  PathItem.Operations dictionary key); the codegen string switch now
  matches on HttpMethod.Method.
- Adjust Discriminator.Mapping value access — values are now
  OpenApiSchemaReference, not raw $ref path strings.

Regression protection landed in #151 (810 unit tests covering public API
surface, model serialization round-trips, enum wire contracts, and
polymorphic dispatch). Generated/* is byte-identical against the committed
bundle on this branch (verified via bash scripts/build-local.sh — zero
drift), so the public API, JSON wire format, and dispatch tables are
provably unchanged.

All 810 unit tests pass on net8.0 and net10.0.

Refs: #67

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jwulf jwulf requested a review from Copilot May 1, 2026 02:47
@jwulf jwulf self-assigned this May 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the generator project to Microsoft.OpenApi 3.5.1 and refactors CSharpClientGenerator to the OpenAPI.NET 3.x model (schema references, schema typing/nullability, enum value reading, and HTTP verb representation), aiming to keep generated output stable.

Changes:

  • Bump Microsoft.OpenApi from 1.6.28 to 3.5.1 and remove the separate Readers package.
  • Switch spec loading to OpenApiModelFactory.LoadAsync and refactor schema consumption to IOpenApiSchema + reference/type/nullability helpers.
  • Replace OperationType usage with System.Net.Http.HttpMethod and update method generation accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/Camunda.Orchestration.Sdk.Generator/Camunda.Orchestration.Sdk.Generator.csproj Updates OpenAPI.NET dependency to 3.5.1 and drops Microsoft.OpenApi.Readers.
src/Camunda.Orchestration.Sdk.Generator/CSharpClientGenerator.cs Refactors generator logic to OpenAPI.NET 3.x surface (document load, schema refs/types/nullability/enums, verb handling).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Camunda.Orchestration.Sdk.Generator/CSharpClientGenerator.cs
Comment thread src/Camunda.Orchestration.Sdk.Generator/CSharpClientGenerator.cs Outdated
Comment thread src/Camunda.Orchestration.Sdk.Generator/CSharpClientGenerator.cs
Comment thread src/Camunda.Orchestration.Sdk.Generator/CSharpClientGenerator.cs
…guard

- HTTP verb switch now normalizes via ToUpperInvariant() and throws on
  unknown verbs instead of silently degrading to GET. Defends against any
  OpenAPI reader that might surface a non-canonical-cased HttpMethod
  (e.g. via a custom HttpMethod ctor).
- Pre-compute isGetLiteral once from the normalized verb instead of
  comparing op.Verb against HttpMethod.Get reference instances at every
  EventualPoller call site (4 sites collapsed to one source of truth).
- Replace 'p.Name ?? string.Empty' fallbacks (path + query params) with
  RequireParameterName helper that fails fast with operationId context.
  OpenAPI requires every parameter to declare a non-empty name; falling
  back to empty string would silently emit invalid C# identifiers and
  broken path/query assembly.

Zero Generated/* drift; 810/810 tests pass on net8.0 and net10.0.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@emilyoram emilyoram merged commit ff7a0ce into main May 5, 2026
9 checks passed
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.

Microsoft.OpenApi update breaks build

3 participants