Skip to content

Conversation

sergey-tihon
Copy link
Member

@sergey-tihon sergey-tihon commented Aug 31, 2025

@sergey-tihon sergey-tihon changed the title feat: update dependencies WIP: Microsoft.OpenApi v2.3.0 with OpenAPI v3.1 Support Aug 31, 2025
@Copilot Copilot AI review requested due to automatic review settings October 11, 2025 22:07
Copy link
Contributor

@Copilot 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

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.

ns.ReleaseNameReservation tyName
ty
| _ -> failwithf $"Cannot compile object '%s{tyName}' based on unresolved reference '{schemaObj.Reference.ReferenceV3}'"
| _ -> failwithf $"Cannot compile object '%s{tyName}' based on unresolved reference '{schemaRef.Reference.Id}'"
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

The pattern matching assumes all schema references are OpenApiSchemaReference types, but the original code handled UnresolvedReference property checks. This change may not handle all reference scenarios correctly and could cause runtime type cast exceptions if the schema object is not actually an OpenApiSchemaReference.

Suggested change
| _ -> failwithf $"Cannot compile object '%s{tyName}' based on unresolved reference '{schemaRef.Reference.Id}'"
| _ ->
let refId =
if not (isNull (box schemaObj)) then
let t = schemaObj.GetType()
let prop = t.GetProperty("Reference")
if not (isNull prop) then
let refVal = prop.GetValue(schemaObj, null)
if not (isNull refVal) then
let idProp = refVal.GetType().GetProperty("Id")
if not (isNull idProp) then
let idVal = idProp.GetValue(refVal, null)
if not (isNull idVal) then idVal.ToString() else null
else null
else null
else null
else null
let refMsg = if String.IsNullOrEmpty(refId) then "(unknown reference)" else refId
failwithf $"Cannot compile object '%s{tyName}' based on unresolved reference '%s{refMsg}' (actual type: %s{if isNull schemaObj then "null" else schemaObj.GetType().FullName})"

Copilot uses AI. Check for mistakes.

Comment on lines +470 to +472
// if path.Value.UnresolvedReference then
// failwith
// $"TP does not support unresolved paths / external references. Path '%s{path.Key}' refer to '%s{path.Value.Reference.ReferenceV3}'"
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

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

Commented out unresolved reference validation without providing an alternative mechanism. This removes important error handling that prevents processing of unresolved external references, which could lead to runtime failures.

Suggested change
// if path.Value.UnresolvedReference then
// failwith
// $"TP does not support unresolved paths / external references. Path '%s{path.Key}' refer to '%s{path.Value.Reference.ReferenceV3}'"
if path.Value.UnresolvedReference then
failwith
$"TP does not support unresolved paths / external references. Path '%s{path.Key}' refer to '%s{path.Value.Reference.ReferenceV3}'"

Copilot uses AI. Check for mistakes.

Comment on lines +392 to +407
// 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
Copy link

Copilot AI Oct 11, 2025

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.

Copilot uses AI. Check for mistakes.

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.

1 participant