-
Notifications
You must be signed in to change notification settings - Fork 60
feat: Microsoft.OpenApi v2.x (OpenAPI v3.1 Support) and .NET 10 #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades Microsoft.OpenApi from v2.x to v2.3.0 to add OpenAPI v3.1 support, removing the separate Microsoft.OpenApi.Readers dependency and updating various dependencies.
Key changes:
- Updated OpenAPI library dependencies and added OpenAPI v3.1 support
- Refactored code to use new OpenAPI library interfaces and APIs
- Modernized F# syntax with abbreviated lambda expressions
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| paket.dependencies | Updated FSharp.Core, System.Text.Json, and OpenAPI packages; added Swashbuckle preview |
| src/SwaggerProvider.DesignTime/v3/DefinitionCompiler.fs | Adapted to new IOpenApiSchema interface and JsonSchemaType enum |
| src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs | Updated to use IOpenApiPathItem and IOpenApiParameter interfaces |
| tests/Swashbuckle.WebApi.Server/Startup.fs | Replaced SerializeAsV2 with OpenApiVersion property |
| tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs | Updated OpenAPI document parsing to use new API |
| src/SwaggerProvider.DesignTime/Provider.OpenApiClient.fs | Updated schema reading to use new OpenAPI parsing methods |
| Multiple files | Applied F# syntax modernization and version updates |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // If schemaObj.Type is missing, but allOf is present and first allOf subschema has a type, use that | ||
| if | ||
| not schemaObj.Type.HasValue | ||
| && not(isNull schemaObj.AllOf) | ||
| && schemaObj.AllOf.Count > 0 | ||
| then | ||
| let firstAllOf = schemaObj.AllOf.[0] | ||
|
|
||
| if not(isNull firstAllOf) && firstAllOf.Type.HasValue then | ||
| Some firstAllOf.Type.Value | ||
| else | ||
| None | ||
| else if schemaObj.Type.HasValue then | ||
| Some schemaObj.Type.Value | ||
| else | ||
| None |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code accesses schemaObj.AllOf.[0] without null checking schemaObj.AllOf first. While there's a count check, if schemaObj.AllOf is null, Count property access will throw a NullReferenceException.
There was a problem hiding this comment.
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 28 out of 29 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
tests/SwaggerProvider.Tests/Schema.Parser.Tests.fs:36
- The diagnostic error checking code is commented out (lines 32-36). If the diagnostic errors are no longer being checked after the migration to OpenApi v2.x, this could lead to silent parsing failures. Either remove the commented code if it's no longer needed, or provide an explanation for why error checking has been disabled. If the API for checking diagnostics has changed, update the code to use the new API.
(* if diagnostic.Errors.Count > 0 then
failwithf "Schema parse errors:\n- %s"
(diagnostic.Errors
|> Seq.map (fun e -> e.Message)
|> String.concat ";\n- ")*)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // NOTE: Dictionary tests removed because Swashbuckle doesn't generate 'additionalProperties' in Swagger 2.0 for dictionaries | ||
| // The swagger.json produces: {"type": "object"} instead of {"type": "object", "additionalProperties": {"$ref": "#/definitions/PointClass"}} | ||
| // The corresponding OpenAPI 3.0 tests in v3/Swashbuckle.ReturnControllers.Tests.fs cover this functionality | ||
| // See: tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.ReturnControllers.Tests.fs for working dictionary tests |
Copilot
AI
Dec 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Swashbuckle doesn't generate 'additionalProperties' in Swagger 2.0 for dictionaries". However, if the tests have been removed due to a known limitation in the test server setup rather than an actual issue in SwaggerProvider itself, this should be made clearer. Consider adding information about whether this is a temporary workaround and if there's a plan to re-enable these tests once Swashbuckle is fixed, or if this represents a permanent limitation.
| // NOTE: Dictionary tests removed because Swashbuckle doesn't generate 'additionalProperties' in Swagger 2.0 for dictionaries | |
| // The swagger.json produces: {"type": "object"} instead of {"type": "object", "additionalProperties": {"$ref": "#/definitions/PointClass"}} | |
| // The corresponding OpenAPI 3.0 tests in v3/Swashbuckle.ReturnControllers.Tests.fs cover this functionality | |
| // See: tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.ReturnControllers.Tests.fs for working dictionary tests | |
| // NOTE: Dictionary tests for the Swagger 2.0 endpoint are disabled here because the Swashbuckle test server | |
| // (and its Swagger 2.0 generator) does not emit 'additionalProperties' for dictionary types. | |
| // The generated swagger.json currently contains: {"type": "object"} instead of | |
| // {"type": "object", "additionalProperties": {"$ref": "#/definitions/PointClass"}}. | |
| // This is a limitation of the Swashbuckle/Swagger 2.0 test setup, not of SwaggerProvider itself. | |
| // The corresponding OpenAPI 3.0 tests in v3/Swashbuckle.ReturnControllers.Tests.fs validate dictionary support. | |
| // See: tests/SwaggerProvider.ProviderTests/v3/Swashbuckle.ReturnControllers.Tests.fs for working dictionary tests. | |
| // If Swashbuckle's Swagger 2.0 generator is ever updated to emit 'additionalProperties' correctly, | |
| // these v2 dictionary-return tests can be re-enabled. |
Uh oh!
There was an error while loading. Please reload this page.