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

Fix Kotlin default values for strings and arrays #9865

Merged
merged 3 commits into from
Jul 21, 2021

Conversation

sigand
Copy link
Contributor

@sigand sigand commented Jun 29, 2021

To close #9844

This PR fixes two of the three issues mentioned in the linked issue. Enum default values were not a priority, as there is a reasonable workaround. All changes were tested with a minimal spec included below.

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/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@jimschubert @dr4ke616 @karismann @Zomzog @andrewemery @4brunu @yutaka0m

@sigand
Copy link
Contributor Author

sigand commented Jun 29, 2021

{
  "openapi": "3.0.1",
  "info": {
    "title": "Test file",
    "version": "1"
  },
  "paths": { },
  "components":{
    "schemas": {
      "Test": {
        "title": "TestObject",
        "type": "object",
        "required": [
          "testArray", "stringDefault"
        ],
        "properties": {
          "stringDefault": {
            "type": "string",
            "default": "test"
          },
          "testArray": {
            "type": "array",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "testArrayOptional": {
            "type": "array",
            "default": ["1"],
            "items": {
              "type": "string"
            }
          },
          "testArrayInt": {
            "type": "array",
            "default": [1, 2],
            "uniqueItems": true,
            "items": {
              "type": "integer"
            }
          }
      }
    }
  }
}

@4brunu
Copy link
Contributor

4brunu commented Jun 30, 2021

Does this PR overlap with #9849?

@sigand
Copy link
Contributor Author

sigand commented Jun 30, 2021

Does this PR overlap with #9849?

Yeah, somewhat.
Same solution for the String quotation problem. Though it is in different templates.
For the unique items, this one is concerned with default values, while the other seems to be concerned with the data type itself.

@wing328
Copy link
Member

wing328 commented Jul 9, 2021

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328 wing328 changed the title FIX #9844 Kotlin default values for strings and arrays Kotlin default values for strings and arrays Jul 9, 2021
@wing328 wing328 changed the title Kotlin default values for strings and arrays Fix Kotlin default values for strings and arrays Jul 9, 2021
@wing328 wing328 added this to the 5.2.1 milestone Jul 21, 2021
@wing328
Copy link
Member

wing328 commented Jul 21, 2021

Tested kotlin-spring generator with default values for string, array of string and the result is good.

@wing328 wing328 merged commit 352ff98 into OpenAPITools:master Jul 21, 2021
@sigand
Copy link
Contributor Author

sigand commented Jul 26, 2021

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

honestly, I don't care :)

@sigand sigand deleted the BUGFIX-9844-kotlin-default-values branch July 19, 2022 16:18
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.

[BUG] [Kotlin-spring] Multiple errors in model default values
3 participants