Skip to content
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

[BUG] [csharp-netcore] When requestBody has OneOf, then it generates client with "UNKNOWN_BASE_TYPE" #9788

Closed
5 of 6 tasks
prajon84 opened this issue Jun 16, 2021 · 2 comments

Comments

@prajon84
Copy link
Contributor

prajon84 commented Jun 16, 2021

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

When the requestBody has oneOf properties, then the client is generated with UNKNOWN_BASE_TYPE as a request parameter.

openapi-generator version

master @ e600f7d

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: C# Object with requestBody has oneOf
  version: v1
paths:
  '/hello':
    patch:
      responses:
        '200':
          description: returns compared object
          content:
            application/json:
              schema:
                type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: string
                - type: integer
Generation Details
Steps to reproduce
>openapi-generator generate -g csharp-netcore -i openapi.yaml --library httpclient -o out/requestBody_with_oneOf/ --model-package Model --api-package Api

>cd out/requestBody_with_oneOf
>dotnet build --configuration Release

produces:

C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(299,34): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(36,27): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(311,83): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(67,61): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(47,52): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(79,86): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(356,74): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Api\DefaultApi.cs(369,123): error CS0246: The type or namespace name 'UNKNOWN_BASE_TYPE' could not be found (are you missing a using directive or an assembly reference?) [C:\Projects\ssh_clone\try-for-openapi-issue\requestBody_with_oneOf\src\Org.OpenAPITools\Org.OpenAPITools.csproj]
Related issues/PRs

None that I could find.

Suggest a fix

@wing328 @Blackclaws @shibayan @lucamazzanti @devhl-labs @jfeltesse-mdsol

@jfeltesse-mdsol
Copy link
Contributor

Probably related to #5903

The root cause is in the generator core itself and as such affects multiple languages.

@wing328
Copy link
Member

wing328 commented May 13, 2022

This should be fixed via #12353. Please pull the latest master to give it a try.

Happy to reopen this issue if needed.

@wing328 wing328 closed this as completed May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants