Skip to content

fix(typescript-angular): Fix 'date' format transform to 'string'#4869

Closed
Xambey wants to merge 8 commits intoOpenAPITools:masterfrom
Xambey:fix_issue_4170
Closed

fix(typescript-angular): Fix 'date' format transform to 'string'#4869
Xambey wants to merge 8 commits intoOpenAPITools:masterfrom
Xambey:fix_issue_4170

Conversation

@Xambey
Copy link
Contributor

@Xambey Xambey commented Dec 26, 2019

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

Fix 'date' format type transform to 'string' type

@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11)

typeMapping.put("Map", "any");
typeMapping.put("map", "any");
typeMapping.put("date", "string");
typeMapping.put("date", "Date");
Copy link
Member

Choose a reason for hiding this comment

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

This should not be changed for alle typescript generators, as Date serialization/deserialization logic may vary.
Moreover, the angular generator does not implement a deserialization logic, so it should remain string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@macjohnny Ok, but why a string in that case hasnt ISO format?

Copy link
Member

Choose a reason for hiding this comment

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

The consuming client / the backend needs to generate strings in iso format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The consuming client / the backend needs to generate strings in iso format

maybe then it is worth making a cast to ISO format? I don't mind having a type be a string if it is handled the same as the date format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you do not use ISO, how will you supply the timezone for the date?

Copy link
Member

Choose a reason for hiding this comment

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

the string is not formatted by the client, it has to be passed by the consumer in the correct ISO format that the backend will understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments