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][aspnetcore] useNewtonsoft=false still generates newtonsoft type converter attributes in enum #12952

Closed
bergziege opened this issue Jul 20, 2022 · 1 comment · Fixed by #15515

Comments

@bergziege
Copy link

bergziege commented Jul 20, 2022

Description

When using the aspnetcore generator to generate an enumeration I get [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] and a reqpective using.

After I set useNewtonsoft: false in a config yml file I would expect the JsonConverter attribute and using to not be generated but still getting the attribute and using in my generated code.

openapi-generator version

v6.0.1 via Docker

OpenAPI declaration file content or url
Generation Details

Powershell script to run the generator in docker:
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v6.0.1 generate -i /local/openapi.yml -o /local/out/aspnetcore -g aspnetcore -c /local/aspnetcoreConfig.yml

openapi.yml:

openapi: "3.0.4"

info:
  title: enum-example
  version: "0.1"

servers:
  - url: /api

paths:
  /test:
    get:
      operationId: getEnum
      summary: Get enumeration value
      tags:
        - test
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      data:
                        $ref: "#/components/schemas/ExampleEnum"

components:
  schemas:
    ExampleEnum:
      type: string
      example: option1
      enum:
        - option1
        - option2
        - option3

aspnetcoreConfig.yml:

enumValueSuffix: ""
enumNameSuffix: ""
useNewtonsoft: false
Steps to reproduce

Run the generator and have a look at the generated ExampleEnum.cs file.

Related issues/PRs

none found

Suggest a fix

No idea other then the expected outcome. Don't know if this is a real bug or some sort of "feature".

@JFCote
Copy link
Member

JFCote commented May 15, 2023

I have create a PR to fix this, feedback is welcome and review too! #15515

wing328 pushed a commit that referenced this issue May 16, 2023
* Fix #12952: Handle useNewtonsoft parameter correctly
Next commit will have all modified samples.

* Fix #12952: Add generated samples

* Fix #12952: Add missing files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants