MarcoMuellner / openapi-python-generator

A client generator from openapi for python.
MIT License
56 stars 25 forks source link

pydantic2 #50

Closed jessemyers-lettuce closed 1 year ago

MarcoMuellner commented 1 year ago

Hi @jessemyers-lettuce, thanks for your PR :) Can you please add tests? Also both versions of Pydantic should be supported. Thank you

jessemyers-lettuce commented 1 year ago

@MarcoMuellner Apologies, I didn't mean to submit this PR yet. I was making one against our own fork so I could test these changes and yours was the default origin.

That said, I'd love to contribute and get this upstreamed, but I think I'll need more guidance. The tests can't just be made to work without changing the project dependencies. If you want both versions of pydantic to be supported, there'll need to be some changes to the pyproject.toml structure... and I'm not really sure how to do that without breaking existing usage.

MarcoMuellner commented 1 year ago

I guess it wouldn't be that difficult - and i don't think it really requires changes to the pyproject.toml file. There would need to be a --useDeprecatedPydantic option for the code, where the models would then be in the form of a pydantic 1 style. By default your version can be used.

So we would need a second jinja2 file for the models, one for each pydantic version. Does this make sense?

jessemyers-lettuce commented 1 year ago

So we would need a second jinja2 file for the models, one for each pydantic version

I ran into a problem doing that because the project itself uses pydantic and uses it for validation; it's been a few weeks so I don't recall the exact error, but it was something along the lines of trying to use v1 to validate v2 templates.