Skip to content

OpenApiClientProvider cannot parse Immich spec - allOf data model with single item #279

Closed

Description

@malacandrian

Reproduction Steps

Run the following script:

#r "nuget: SwaggerProvider, 2.3.2"
open SwaggerProvider

let [<Literal>] Schema = "https://raw.githubusercontent.com/immich-app/immich/refs/heads/main/open-api/immich-openapi-specs.json"
type Immich = OpenApiClientProvider<Schema>
let client = Immich.Client()

The following error is returned:

Duplicate in method table is:
  Type index: 8
  Method name: .ctor
  Method arity (num generic params): 0

Error: input.fsx (4,15)-(4,44) typecheck error The type provider 'SwaggerProvider.OpenApiClientTypeProvider' reported an error: Error in pass2 for type Immich, error: Error in pass2 for type ActivityCreateDto_Type, error: duplicate entry '.ctor' in method table
input.fsx (4,15)-(4,44)

Further investigation

If I edit the OpenAPI spec to remove the offending ActivityCreateDto (along with any paths and other DTOs that reference it) it then fails on ActivityResponseDto. Removing ActivityResponseDto causes it to fail on AddUsersDto and so on and so forth.

Where ActivityCreateDto complained about the "Type" property, others complained about the "Error", "Role", or "Order" properties. The common thread I have seen across them is that they all use the allOf data model referencing a single item.

Similar issues

Issue #263 also reports parse errors, though they are significantly different. There are two things suggested there:

  1. That it is an issue with the spec. I have already reported this as in issue with Immich, but they believe that their spec is correct and it is the type provider that is incorrect.
  2. That it is an issue with the parser that will be fixed by feat: Microsoft.OpenApi v2.x (OpenAPI v3.1 Support) and .NET 10 #269 upgrading to the latest Microsoft.OpenApi version. I have tried using v3.0.0-beta01 but that did not address the issue.

Issues #135 and #184 also complain about constructors, but they are complaining about missing constructors, not duplicated ones. I could not find any issues referencing a duplicate constructor.

Issue #243 also complains of problems parsing allOf constraints, so this may well be related.

Activity

  1. sergey-tihon commented on Dec 22, 2025

    @sergey-tihon
    Member

    That it is an issue with the parser that will be fixed by #269 upgrading to the latest Microsoft.OpenApi version. I have tried using v3.0.0-beta01 but that did not address the issue.

    Why do you think that upgrade to newer version of Microsoft.OpenApi parser will fix it? Changes from mentioned PR not included in beta version on NuGet.

    We use inheritance and allOf from 2+ refs is problematic... allOf with just one ref is just strange 😐 but should be possible to support with not huge diff.

  2. malacandrian commented on Dec 30, 2025

    @malacandrian
    Author

    Thank you.

    It is no longer complaining about the duplicate constructors, but it appears to set resolvedType to Some (Some Null) which then fails to match when setting tyType.

    typecheck error The type provider 'SwaggerProvider.OpenApiClientTypeProvider' reported an error: Type AssetResponseDto_Stack(Null,) should be caught by other match statement (Some Null)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions