-
Notifications
You must be signed in to change notification settings - Fork 60
Description
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds an IgnoreParseErrors static parameter to OpenApiClientProvider so users can work with non-strictly-compliant schemas (e.g. NSwag/Squidex-generated schemas) without the type provider failing at design time.
Closes #261 (partially — the parse-error half).
Problem
Microsoft.OpenApi.Readers strictly validates the schema and flags extensions like nullable: true placed directly on a parameter object (instead of inside its schema sub-object) as errors. SwaggerProvider currently treats any parse error as fatal and aborts the provider, making it impossible to use otherwise-functional schemas from generators like NSwag.
Changes
src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs
- Added new
IgnoreParseErrorsstatic parameter (defaultfalse— existing strict behaviour unchanged). - When
true, parse errors are printed tostderras warnings and type generation proceeds. IgnoreParseErrorsis included in the cache key.
tests/SwaggerProvider.ProviderTests/Schemas/v3/nullable-parameter-issue261.json
- New minimal test schema that places
nullable: trueat the parameter level, reproducing the exact failure reported in properties named "nullable" and subschema components #261.
tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs
- Two new facts:
Schema with nullable parameter-level property triggers parse errors— documents thatMicrosoft.OpenApidoes report this as an error (soft assertion: passes even if a future parser version becomes lenient).Schema with nullable parameter is still parseable despite errors— verifies the schema can be compiled by the DefinitionCompiler/OperationCompiler even when diagnostics are present.
global.json
- Relaxes the SDK pin from the exact
10.0.103(which may not be installed) toversion: 10.0.100 rollForward: latestPatch, so the build works with any available 10.0.x patch version.
Usage
// schema.json contains non-spec-compliant fields (e.g. NSwag-generated)
type MyApi = OpenApiClientProvider<"schema.json", IgnoreParseErrors=true>
```
## Trade-offs
- **Correctness**: Users opting in accept that the generated types may differ from what a strictly-compliant schema would produce, since some type information may be in the skipped fields.
- **No breaking change**: Default is `false`; all existing code is unaffected.
## Test Status
Built and tested (SDK 10.0.102 / net10.0):
```
=== TEST EXECUTION SUMMARY ===
SwaggerProvider.Tests Total: 128, Errors: 0, Failed: 0, Skipped: 2, Not Run: 0, Time: 0.870sThe 2 skips are pre-existing. Fantomas formatting applied.
Generated by Repo Assist · ◷
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f
Warning
🛡️ Protected Files
This was originally intended as a pull request, but the patch modifies protected files: global.json.
These files may affect project dependencies, CI/CD pipelines, or agent behaviour. Please review the changes carefully before creating the pull request.
Click here to create the pull request once you have reviewed the changes
To route changes like this to a review issue instead of blocking, configure protected-files: fallback-to-issue in your workflow configuration.