Skip to content

[Go-Server] Add support for DateTime Query Parameters#16749

Merged
wing328 merged 8 commits intoOpenAPITools:masterfrom
icubbon:go-server/bugFixes/dateTimeSupport
Oct 22, 2023
Merged

[Go-Server] Add support for DateTime Query Parameters#16749
wing328 merged 8 commits intoOpenAPITools:masterfrom
icubbon:go-server/bugFixes/dateTimeSupport

Conversation

@icubbon
Copy link
Contributor

@icubbon icubbon commented Oct 6, 2023

Add support to the Go-Server template to parse DateTime parameters in the Query and as a List in the Query.

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
    
    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 (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.

@lwj5 @wing328

@lwj5
Copy link
Contributor

lwj5 commented Oct 10, 2023

Hi @icubbon

Thank you for the PR. As there are currently no cases with DateTime in the generation sample, it is difficult to see how the generated files will look.

Would you be able to add a new route or add a datetime field somewhere in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml

then regenerate the code for go-server.

Let us know if you need any help with generation

@icubbon
Copy link
Contributor Author

icubbon commented Oct 12, 2023

Hi @icubbon

Thank you for the PR. As there are currently no cases with DateTime in the generation sample, it is difficult to see how the generated files will look.

Would you be able to add a new route or add a datetime field somewhere in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/go-server/petstore.yaml

then regenerate the code for go-server.

Let us know if you need any help with generation

Good call with the example! An import for time was missing in the api-controller.mustache template but was being added in my personal work setup with a call to goimports.
I had to re-arrange where the parsing was done as the api-controllers.mustache template didn't have good support for dynamic importing.

Copy link
Contributor

@lwj5 lwj5 left a comment

Choose a reason for hiding this comment

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

LGTM, just need to update the following

}

func parseTimes(param string) ([]time.Time, error) {
splits := strings.Split(param, ", ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
splits := strings.Split(param, ", ")
splits := strings.Split(param, ",")

Dont require a space

@lwj5
Copy link
Contributor

lwj5 commented Oct 17, 2023

Will need your help to resolve the conflict before we can merge

@icubbon
Copy link
Contributor Author

icubbon commented Oct 18, 2023

Conflicts resolved, looks like the generated examples have both the Enum changes and the DateTime changes as well.

Copy link
Contributor

@lwj5 lwj5 left a comment

Choose a reason for hiding this comment

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

Lgtm, @wing328 good to merge

@wing328 wing328 merged commit bf9fae6 into OpenAPITools:master Oct 22, 2023
@wing328 wing328 added this to the 7.1.0 milestone Oct 22, 2023
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