Created by: AlexanderEggers
I have noticed an issue with the Kotlin client that was using the LocalDate or LocalDateTime toString
method. Generally that will work for people, but I actually got a use-case where I want to send up a specific date-string format. The toString generally is using the format "yyyy-MM-dd'T'HH:mm:ss" but I want to send up "yyyy-MM-dd'T'HH:mm:ssZ".
I have done a few changes to the existing templates and added a new option for the generator called "requestDateConverter". This option can take the values "toJson" or "toString". "toString" is the default value and ensures not to break any existing code. "toJson" is using the gson/moshi converter to parse the date object. Because the converter is converting the date into a json value I am stripping the quotation marks from the value at the end. Using the json converter, the solution is much simpler and generic.
Changelog:
- Added new samples for showing the date converter stuff
- Updated samples
- Added new generator option via the Kotlin codegen
- Updated jvm templates to use the new "requestDateConverter" option
These changes are for jvm only at the moment. I can take care of the multiplatform part in a different PR.
PR checklist
-
Read the contribution guidelines. -
If contributing template-only or documentation-only changes which will change sample output, build the project before. -
Run the shell script(s) under ./bin/
(or Windows batch scripts under.\bin\windows
) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh
,./bin/openapi3/{LANG}-petstore.sh
if updating the code or mustache templates for a language ({LANG}
) (e.g. php, ruby, python, etc). -
File the PR against the correct branch: master
,4.3.x
,5.0.x
. Default:master
. -
Copy the technical committee to review the pull request if your PR is targeting a particular programming language.