Skip to content

Add support for date format in string types #30

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

Merged
merged 2 commits into from
Apr 25, 2020

Conversation

acgray
Copy link

@acgray acgray commented Apr 12, 2020

Add support for date field format alongside date-time

@acgray acgray changed the title Date field Add support for date format in string types Apr 12, 2020
Copy link
Collaborator

@dbanty dbanty left a comment

Choose a reason for hiding this comment

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

Thanks for the addition! There are a couple things not covered by unit tests like the error when a string format is not recognized and the transform functions on DateTimeProperty and DateProperty.

I think I managed to turn on CircleCI builds for forked pull requests? We'll see. If not you can run pytest --cov=openapi_python_client and then coverage to see what is and isn't covered.

I'd also like to cover each new feature going forward in the end to end tests by declaring something that tests it in the FastAPI app and regenerating openapi.json and the golden master. This is the only way templates are really tested today. If you can't easily get that working it's fine, I can do it after I merge in.

Comment on lines +125 to +128
if isinstance(prop, DateProperty):
self.relative_imports.add("from datetime import date")
if isinstance(prop, DateTimeProperty):
self.relative_imports.add("from datetime import datetime")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I actually always import datetime in templates/model.pyi right now but only importing when needed seems better. Will you remove it from that template?

@codecov
Copy link

codecov bot commented Apr 25, 2020

Codecov Report

Merging #30 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #30   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         9    +1     
  Lines          532       572   +40     
=========================================
+ Hits           532       572   +40     
Impacted Files Coverage Δ
openapi_python_client/__init__.py 100.00% <100.00%> (ø)
openapi_python_client/openapi_parser/openapi.py 100.00% <100.00%> (ø)
openapi_python_client/openapi_parser/properties.py 100.00% <100.00%> (ø)
openapi_python_client/openapi_parser/reference.py 100.00% <100.00%> (ø)
openapi_python_client/openapi_parser/responses.py 100.00% <100.00%> (ø)
openapi_python_client/utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5583d86...48c2af1. Read the comment docs.

@dbanty dbanty merged commit 794672f into openapi-generators:master Apr 25, 2020
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