[Repo Assist] Add SchemaReaderErrors property to OpenApiClientProvider (fixes #160)#327
Merged
sergey-tihon merged 2 commits intomasterfrom Mar 17, 2026
Conversation
…#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>
Contributor
There was a problem hiding this comment.
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 listproperty. - Add a small design-time helper to build a constant
string listquotation for embedding into the provided assembly. - Add provider tests verifying
SchemaReaderErrorsis[]for valid schemas and non-empty for schemas with validation errors whenIgnoreParseErrors=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.
Contributor
|
🙌 looking forward to try this out, seems awesome! |
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is a Repo Assist automated PR.
Summary
Addresses #160 — adds a static
SchemaReaderErrors : string listproperty to the root type generated byOpenApiClientProvider. This surfaces any OpenAPI parse errors that were tolerated whenIgnoreParseErrors=true.The property returns
[]for valid schemas, so it's safe to always call.Implementation
buildStringListExprhelper (usingExpr.NewUnionCase) builds the constant string list at design time and embeds it in the generated assembly.parseErrorscollectsdiagnostic.Errorsasmessage @ pointerstrings after the parse step, regardless ofignoreParseErrorsmode. ForIgnoreParseErrors=falseschemas with errors, the existingfailwithfstill fires first.SchemaReaderErrorsis a staticProvidedPropertyadded to the root generated type, with XML doc.Tests
New
Swagger.SchemaReaderErrors.Tests.fsinSwaggerProvider.ProviderTests/v3/:ValidApi.SchemaReaderErrors→[]for a clean petstore schemaApiWithErrors.SchemaReaderErrors→ non-empty list whenIgnoreParseErrors=trueon a schema with anullableparameter-level validation error@separatorTest 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 filesCloses #160