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][GenericHost] OpenApi 3.1: Model property of type map/additionalproperties gets generated as object #18772

Conversation

gerwinjansen
Copy link
Contributor

PR #17624 introduced an issue when generating code for a model with a property of type map/additionalproperties

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    

Input

Response:
  type: object
  properties:
    success:
      type: boolean
    results:
      additionalProperties: #key-value map
        oneOf:
          - $ref: '#/components/schemas/FileResult'
          - $ref: '#/components/schemas/StringResult'
  required:
    - success
    - results

Expected output

public Response(bool success, Dictionary<string, ResponseResultsValue>? results = default)
{
    Success = success;
    Results = results;
    OnCreated();
}

Actual output

public Response(bool success, Object? results = default)
{
    Success = success;
    Results = results;
    OnCreated();
}

@@ -0,0 +1,14 @@
# for csharp generichost
generatorName: csharp
outputDir: samples/client/petstore/csharp/generichost/net8/OneOfDiscriminator-3.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR, which looks good me.

after merging, i'll replace this test (sample) with a unit test instead similar to other 3.1 tests we've added so far.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done via #18828

@wing328 wing328 merged commit c08afa3 into OpenAPITools:master Jun 2, 2024
26 checks passed
@wing328 wing328 mentioned this pull request Jun 2, 2024
5 tasks
@wing328 wing328 added this to the 7.7.0 milestone Jun 2, 2024
welshm pushed a commit to welshm/openapi-generator that referenced this pull request Jun 5, 2024
…ditionalproperties gets generated as object (OpenAPITools#18772)

* Fix the bug + add test case

* Add sample output

* Update version number in new sample output

---------

Co-authored-by: Gerwin Jansen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants