Skip to content

[Repo Assist] Add SchemaReaderErrors property to OpenApiClientProvider (fixes #160)#327

Merged
sergey-tihon merged 2 commits intomasterfrom
repo-assist/feat-schema-reader-errors-2026-03-17-625531e50b078ffb
Mar 17, 2026
Merged

[Repo Assist] Add SchemaReaderErrors property to OpenApiClientProvider (fixes #160)#327
sergey-tihon merged 2 commits intomasterfrom
repo-assist/feat-schema-reader-errors-2026-03-17-625531e50b078ffb

Conversation

@github-actions
Copy link
Contributor

🤖 This is a Repo Assist automated PR.

Summary

Addresses #160 — adds a static SchemaReaderErrors : string list property to the root type generated by OpenApiClientProvider. This surfaces any OpenAPI parse errors that were tolerated when IgnoreParseErrors=true.

type MyApi = OpenApiClientProvider<"schema.yaml", IgnoreParseErrors=true>

// Inspect which errors were silently tolerated
MyApi.SchemaReaderErrors |> List.iter printfn
// e.g. "Property 'nullable' is not allowed ... @ #/paths/..."

The property returns [] for valid schemas, so it's safe to always call.

Implementation

  • buildStringListExpr helper (using Expr.NewUnionCase) builds the constant string list at design time and embeds it in the generated assembly.
  • parseErrors collects diagnostic.Errors as message @ pointer strings after the parse step, regardless of ignoreParseErrors mode. For IgnoreParseErrors=false schemas with errors, the existing failwithf still fires first.
  • SchemaReaderErrors is a static ProvidedProperty added to the root generated type, with XML doc.

Tests

New Swagger.SchemaReaderErrors.Tests.fs in SwaggerProvider.ProviderTests/v3/:

  • ValidApi.SchemaReaderErrors[] for a clean petstore schema
  • ApiWithErrors.SchemaReaderErrors → non-empty list when IgnoreParseErrors=true on a schema with a nullable parameter-level validation error
  • Each entry confirmed to contain @ separator

Test Status

SwaggerProvider.Tests: 203 passed, 0 failed (2 skipped — pre-existing)
⚠️ SwaggerProvider.ProviderTests: requires live Swashbuckle test server — not run locally; the static-schema tests (Swagger.SchemaReaderErrors.Tests, Swagger.NullableDate.Tests, etc.) compile and are structurally correct
✅ Format check (dotnet fantomas --check): passed on changed files

Closes #160

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…#160)

Exposes parse errors collected during schema loading as a static
'SchemaReaderErrors : string list' property on the generated root type.

- Non-empty only when IgnoreParseErrors=true and the schema has issues
- Each entry formatted as '<message> @ <pointer>' (matches stderr output)
- Returns [] for valid schemas, safe to always inspect

Also adds Swagger.SchemaReaderErrors.Tests covering:
- Valid schema → empty list
- Schema with validation errors + IgnoreParseErrors=true → non-empty list
- Error entries contain both message and pointer parts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review March 17, 2026 20:11
Copilot AI review requested due to automatic review settings March 17, 2026 20:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a discoverable way to retrieve OpenAPI parser validation errors from generated OpenApiClientProvider types, primarily for scenarios where IgnoreParseErrors=true allows generation to proceed despite schema issues.

Changes:

  • Embed parser validation errors into the generated root type via a new static SchemaReaderErrors : string list property.
  • Add a small design-time helper to build a constant string list quotation for embedding into the provided assembly.
  • Add provider tests verifying SchemaReaderErrors is [] for valid schemas and non-empty for schemas with validation errors when IgnoreParseErrors=true.

Reviewed changes

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

File Description
src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs Collects parse errors from OpenApiDocument.Parse diagnostics and exposes them via a new provided static property on the generated root type.
tests/SwaggerProvider.ProviderTests/v3/Swagger.SchemaReaderErrors.Tests.fs Adds tests for the new SchemaReaderErrors property behavior on valid vs. error-tolerated schemas.
tests/SwaggerProvider.ProviderTests/SwaggerProvider.ProviderTests.fsproj Includes the new test file in the ProviderTests project compilation list.

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

You can also share your feedback on Copilot code review. Take the survey.

@sergey-tihon sergey-tihon merged commit 250f832 into master Mar 17, 2026
7 of 8 checks passed
@jkone27
Copy link
Contributor

jkone27 commented Mar 17, 2026

🙌 looking forward to try this out, seems awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema error handling on OpenApiProvider

3 participants