Skip to content

[PYTHON] generate code based on pydantic v2#16469

Closed
oshmoun wants to merge 2 commits intoOpenAPITools:masterfrom
oshmoun:master
Closed

[PYTHON] generate code based on pydantic v2#16469
oshmoun wants to merge 2 commits intoOpenAPITools:masterfrom
oshmoun:master

Conversation

@oshmoun
Copy link

@oshmoun oshmoun commented Aug 31, 2023

In order to generate python clients with support for pydantic v2, some small adjustments are needed to the model templates.
This PR implements the changes, alongside a version update for pydantic in the various requirements lists

fixes #16468

@spacether (2019/11) ❤️ @krjakbrjak (2023/02)

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/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.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date
    
    Commit all changed files.
  • File the PR against the correct branch: master (7.0.1 - patch release), 7.1.x (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.

@oshmoun oshmoun changed the title python: generate code based on pydantic v2 [PYTHON] generate code based on pydantic v2 Aug 31, 2023
@UltimateLobster
Copy link

Hey! :D
I'm just a nobody who really wants to see this getting through. Thank you so much for doing this! This blocks my team from using openapi-generator (we use pydantic 2 features and the generated clients prevents us from installing them unless we switch back to pydantic 1)

I have a question though, won't this change break compatibilty with existing users? After all, you don't just add compatibility with pydantic 2, but also drop compatilibility with pydantic 1.

@oshmoun
Copy link
Author

oshmoun commented Sep 8, 2023

Thank you so much for doing this! This blocks my team from using openapi-generator (we use pydantic 2 features and the generated clients prevents us from installing them unless we switch back to pydantic 1)

Glad to know this proves helpful for somebody 🙂

I have a question though, won't this change break compatibilty with existing users? After all, you don't just add compatibility with pydantic 2, but also drop compatilibility with pydantic 1.

Well tbh I didn't consider that at all, and simply assumed that since the client is generated alongside dependencies (at default settings), it's ok to simply upgrade the whole thing and ignore backwards compatibility. Implementing such a thing would probably require introducing a new config parameter to select pydantic version. I'll leave that decision to people who have more experience with things openapi (I'm also a nobody who just wants this done 😁)

@wing328
Copy link
Member

wing328 commented Sep 10, 2023

I've filed #16549 to add an option usePydanticV2 and add the ptestore samples but not all tests passed. Please take a look when you've time. Thanks.

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.

[PYTHON] update to pydantic v2

3 participants