Skip to content

[BUG] [Csharp-Netcore] Handle custom Content-type issue #12835

@the-akhil-nair

Description

@the-akhil-nair

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?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

#12460: Addresses the solution to use our own content type.
But after this change, we are facing an issue while building the chsarp-netcore SDK.

openapi-generator version

6.0.1

OpenAPI declaration file content or url

https://gist.githubusercontent.com/the-akhil-nair/59a53af4c626dde4e5f6717423f55f95/raw/78cad7f25c3ed0e473bc0a85a4b1d6b204729727/spec.yaml

Generation Details

config.yaml

generatorName: csharp-netcore
outputDir: generated_new/
#templateDir: csharp-netcore
inputSpec: https://gist.githubusercontent.com/the-akhil-nair/59a53af4c626dde4e5f6717423f55f95/raw/78cad7f25c3ed0e473bc0a85a4b1d6b204729727/spec.yaml
optionalEmitDefaultValues: true
conditionalSerialization: true
removeEnumValuePrefix: false 
useCompareNetObjects: true 
disallowAdditionalPropertiesIfNotPresent: false
useOneOfDiscriminatorLookup: true
targetFramework: netcoreapp3.1
java -jar openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -c config.yaml
Exception in thread "main" java.lang.RuntimeException: Could not generate api file for 'Default'
        at org.openapitools.codegen.languages.AbstractCSharpCodegen.postProcessOperationsWithModels(AbstractCSharpCodegen.java)at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:686)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:914)
        at org.openapitools.codegen.cmd.Generate.execute(Generate.java:465)
        at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Caused by: java.lang.NullPointerException
        at org.openapitools.codegen.languages.AbstractCSharpCodegen.postProcessOperationsWithModels(AbstractCSharpCodegen.java:736)
        at org.openapitools.codegen.DefaultGenerator.processOperations(DefaultGenerator.java:1234)
        at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:590)
        ... 4 more
Steps to reproduce

Use the aforementioned command to reproduce the issue.

Related issues/PRs

NA

Suggest a fix

The following line:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/examples/ExampleGenerator.java#L174

Can be modified as follows:

kv.put(EXAMPLE, "null");

Since the EXAMPLE will be parsed in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java#L736-L739 and will be treated as a string the above fix will solve the issue.

@wing328

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