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][C#] UNKNOWN_BASE_TYPE with ref on allOf #17962

Closed
5 tasks done
acandylevey opened this issue Feb 26, 2024 · 2 comments
Closed
5 tasks done

[BUG][C#] UNKNOWN_BASE_TYPE with ref on allOf #17962

acandylevey opened this issue Feb 26, 2024 · 2 comments

Comments

@acandylevey
Copy link

acandylevey commented Feb 26, 2024

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?
Description

When generating the C# client when the request body has been put into a allOf via a $ref the generated code always contained UNKNOWN_BASE_TYPE.

This changed recently in our code base as we started using config.UseAllOfToExtendReferenceSchemas(); with Swashbuckle.

Prior to this, we always generated our schema as below which didn't cause any issues.

 application/json:
            schema:
              $ref: '#/components/schemas/CustomRequest'
openapi-generator version

7.3.0

OpenAPI declaration file content or url
/api/custom-endpoint:
    post:
      requestBody:
        content:
          application/json-patch+json:
            schema:
              allOf:
              - $ref: '#/components/schemas/CustomRequest'
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/CustomRequest'
          text/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/CustomRequest'
          application/*+json:
            schema:
              allOf:
              - $ref: '#/components/schemas/CustomRequest'
      responses:
        "200":
          content:
            text/plain:
              schema:
                items:
                  $ref: '#/components/schemas/CustomResponse'
                type: array
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/CustomResponse'
                type: array
            text/json:
              schema:
                items:
                  $ref: '#/components/schemas/CustomResponse'
                type: array
          description: Success
      security:
      - API-Key: []
      tags:
      - CustomTag
Generation Details

openapi-generator-cli generate -i .\api-swagger.json -g csharp -o ./client -p disallowAdditionalPropertiesIfNotPresent=false -p targetFramework=net6.0 -p packageName=Org.Domain.Api-p netCoreProjectFile=true -p nullableReferenceTypes=true -p useCollection=true -p library=httpclient -p useSingleRequestParameter=true

Steps to reproduce

Generate with the above yaml and you'll get UNKNOWN_BASE_TYPE

Related issues/PRs

#2236

@wing328
Copy link
Member

wing328 commented Feb 26, 2024

can you please share the spec (minimal) to reproduce the issue?

I tired to reproduce with allOf in request/response but couldn't.

@howlettt
Copy link

howlettt commented Jul 8, 2024

I ran into this issue when using version 7.0.1 of the cli, updating to the latest 7.7.0 fixed it

@wing328 wing328 closed this as completed Aug 7, 2024
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