Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

v3 uses generics in schemas so IDEs can see instance and property base types#169

Closed
spacether wants to merge 7 commits into3_0_0from
v3_generic
Closed

v3 uses generics in schemas so IDEs can see instance and property base types#169
spacether wants to merge 7 commits into3_0_0from
v3_generic

Conversation

@spacether
Copy link
Copy Markdown
Contributor

@spacether spacether commented May 10, 2023

v3 makes all schema classes based on Generic[T]
So now when models are instantiated, they will show what class they are based on
Like so:

my_model = MyModel(some_str='a')
# my_model is type MyModel[frozendict.frozendict] in the vscode IDE
# my_model.some_str is type SomeStr[str] in the vscode IDE
  • keep the mixin classes for ide methods (needed to show possible properties)
  • make Schema generic
  • when making classes always define new so the generic can be seen
  • update properties to add the generic type
  • var equals class define class instead, needed for generics
  • update ref props to add generic
  • fix UnsetAnyTypeSchema not being used in AbstractStepMessage
  • update get_item property with type
  • update get_item array with type
  • add __init__ method to AnyTypeSchema
  • update parameter and header schema and content type definition to be [typed]
  • change ref schemas to be type aliases

Out of scope future improvement. Use typing.Never in NotAnyType

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/python*.
    For Windows users, please run the script in Git BASH.

spacether and others added 6 commits May 4, 2023 15:47
* Removes get_item_

* Samples and docs updated

* Fixes python tests
* Removes overrides from api classes

* Fixes type hint for operation methods, reduced 2x duplication

* Samples updated

* Sample regen
* Converts PrefixSeparatorIterator, Api, and Encoding into dataclasses

* ApiClient converted to dataclass

* Removes __call_api

* Removes unneeded type imports from header

* Removes unneeded imports from headers

* Removes unneeded imports in responses when they have no content or headers

* Removes unneeded header imports

* Removes pyi files

* Removes functools import

* Stops generating new for anytype schemas

* Samples regenerated

* Fixes this_package security tests
* petstore regen

* removes init template

* Adds parameters type hint

* Centralizes path and query param serialization

* Removes type hint for param tuples

* Simplifies used_path definition

* Adds path + query params inputs

* Adds _get_headers

* SImplifies header assignment

* Adds _get_field_and_body

* Adds _verify_response_status

* Removes unused imports

* Removes unused import

* Updates method name

* Samples regenerated
* Adds typing_imports

* Adds typing_imports for header and parameter

* Updates request body imports

* Adds response_imports

* Adds schema_imports

* Adds security_scheme_imports

* Adds server imports

* Adds operation_imports

* typing_imports -> header_imports

* Sample regen
@spacether spacether changed the title v3 generic v3 uses generics in schemas so IDEs can see instance and property base types May 11, 2023
@spacether
Copy link
Copy Markdown
Contributor Author

Closing this and work will continue on in #174
Starting a new PR was easier than rebasing this one

@spacether spacether closed this May 17, 2023
@spacether spacether deleted the v3_generic branch May 17, 2023 20:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant