Skip to content

[BUG] C# GenerericHost - Exception #18607

Closed
@marcselman

Description

@marcselman

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
Description

When trying to generate C# output using the GenericHost library I get an exception.
java.lang.IllegalArgumentException: Comparison method violates its general contract!
If I remove some property from the component schema or if I remove some required properties, the error goes away.
It looks like the specific combination of properties in the file somehow cause the error.

This is the whole error:

Exception in thread "main" java.lang.RuntimeException: Could not process model 'MixLog'.Please make sure that your schema is correct!
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:542)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:1228)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:535)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
        at java.base/java.util.TimSort.mergeLo(TimSort.java:781)
        at java.base/java.util.TimSort.mergeAt(TimSort.java:518)
        at java.base/java.util.TimSort.mergeCollapse(TimSort.java:448)
        at java.base/java.util.TimSort.sort(TimSort.java:245)
        at java.base/java.util.Arrays.sort(Arrays.java:1308)
        at java.base/java.util.ArrayList.sort(ArrayList.java:1804)
        at java.base/java.util.Collections.sort(Collections.java:178)
        at org.openapitools.codegen.languages.CSharpClientCodegen.fromModel(CSharpClientCodegen.java:469)
        at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1683)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:537)
        ... 4 more
openapi-generator version

7.5.0

OpenAPI declaration file content or url

https://gist.github.com/marcselman/78b1516e5a15c92da70a31c851c11c6c

Generation Details
openapi-generator-cli generate -g csharp -o "./client" --package-name "Demonstration" -i "openapi.2023.11.0.json" --additional-properties "library=generichost,nullableReferenceTypes=true,netCoreProjectFile=true,disallowAdditionalPropertiesIfNotPresent=false,targetFramework=net8.0,generateAliasAsModel=false,useDateTimeOffset=true,validatable=true,equatable=false,modelPropertyNaming=PascalCase,useCollection=false,returnICollection=false"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions