Skip to content

Conversation

@ErikBooijMB
Copy link
Contributor

Hi folks! I'm running into an issue with generated go-server code, and to be completely honest, I'm not 100% sure this is the fix, I just know it solves my problem, but I cannot really judge which unintended side effects it may have.

When I have an OpenAPI spec that has parameters typed as enums:

{
  "name": "entityType",
  "in": "query",
  "description": "Entity type",
  "schema": {
    "type": "string",
    "enum": [
      "OPTION_1",
      "OPTION_2",
      "OPTION_3"
    ]
  }
}

This currently generates the following code:

entityTypeParam, err = NewstringFromValue(query.Get("entityType"))

But that's a function that does not exist. I'm not sure this part of the template is really supposed to apply to enum values. I just know that overriding this template locally which this change, my generated code compiles. If this change makes sense, there are still different instances of isEnumOrRef in this template, and I'm also not sure if the same change should be applied there.

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
    

Unfortunately I cannot install Java on my machine, so this is not an option, sorry.

  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. /cc @lwj5

@lwj5
Copy link
Contributor

lwj5 commented Dec 5, 2023

could you help to change all previous instances of

isEnumOrRef to isEnumRef

in this particular file. I'll add the test in another PR, so that you can get the contribution

@ErikBooijMB ErikBooijMB force-pushed the fix/go-server-enum-param branch from 12c518d to 827d908 Compare December 5, 2023 14:45
@lwj5
Copy link
Contributor

lwj5 commented Dec 5, 2023

I think the changes are incorrect should be isEnumRef

@ErikBooijMB
Copy link
Contributor Author

You're right, my bad. Fixing now and just making sure this still generates the expected code on my end.

@ErikBooijMB
Copy link
Contributor Author

Btw, if it's easier and you'd rather include this change in your PR with the test (which I greatly appreciate 🙇 ), I'm also fine with just closing this PR and leaving it to you. As much as I respect and appreciate your consideration for my contribution stats, I don't really mind, and I'm already a very happy camper if it gets resolved 😌 (and your response time is amazing btw 😃)

@lwj5
Copy link
Contributor

lwj5 commented Dec 6, 2023

no problem, I'll add it later

LGTM @wing328 please merge. Will add tests later. tested locally

@wing328 wing328 merged commit 95af601 into OpenAPITools:master Dec 8, 2023
@wing328 wing328 added this to the 7.2.0 milestone Dec 8, 2023
@lwj5 lwj5 mentioned this pull request Dec 13, 2023
5 tasks
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.

3 participants