Skip to content
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

v3 convert nested schemas into sequential schemas #177

Merged
merged 57 commits into from
Jun 6, 2023

Conversation

spacether
Copy link
Contributor

@spacether spacether commented May 29, 2023

v3 convert nested schemas into sequential schemas

  • converted Schema_ classes into dataclasses to allow for delayed evaluation of all_of/any_of/one_of/not/additional_properties/items/properties via default_factory
  • added a singleton metaclass to schemas so there is only one instance of each Schema_
  • Note: another solution here is classproperty decorated methods which would not required the dataclass and but that takes up more space (lines)
  • Added enum generic types
  • Server variables input changed to an instance of a DictSchema class
    • variables are properties that can be enums
    • classproperty enum type hints must be defined on a class that is not nested per vscode

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 spacether changed the title v3 removes nested schemas v3 convert nested schemas into sequential schemas May 31, 2023
@spacether spacether merged commit 802b5cc into 3_0_0 Jun 6, 2023
@spacether spacether deleted the v3_removes_nested_schemas branch June 6, 2023 17:49
spacether added a commit that referenced this pull request Jun 8, 2023
* Writes nested schemas earlier and uses them later

* Refactors order CodegenSchema properties are set in to match the order in getSchemas

* Adjusts ref input to setSchemaLocationInfo

* Tweak improves schema template

* Adds properties classes

* Replaces properties with field

* Uses Schema_()

* Uses dataclass properties

* Adds missing type info

* Updates all_of

* Adds any_of, all_of tuples

* Fixes types definition

* Fixed test_any_type_schema tests

* Fixes dataclass type setting issues

* Fixes simple schema format type

* Adds and uses PatternInfo for pattern schema info, validate_regex changed to validate_pattern

* Fixes not constraint tests

* Adds tuple_to_instance

* Writes out allOf/anyOf/oneOf types

* Updates classproperty decorator

* Adds enum return types

* Fixes type errors in schemas.py

* Adds schema singleton metaclass

* Replaces CodegenServer variables with object schema containing variables in properties

* Generates server variables as an object schema to keep all schemas at the root depth

* Fixes new signatures in servers schemas

* Simplifies Server variables definition

* Uses schema default for server variables

* Adds required vars in server definition

* Fixes classproperty and SchemaBase classes

* Fixes broken configuration tests

* Fixes server docs

* Adds isInlineDefinition

* Adds allOf/anyOf/oneOf/properties jsonPathPiece

* Uses jsonPathPiece in properties/allOf/anyOf/oneOf

* Fixes properties typeddict name

* Templates updated to write allOf/anyOf/oneOf/properties earlier if possible

* generates properties/allOf/anyOf/oneOf before class if possible

* Adds and uses schemas.INPUT_TYPES_ALL_INCL_SCHEMA

* Adds another usage of schemas.INPUT_TYPES_ALL_INCL_SCHEMA

* Changes SchemaBase to SingletonMeta

* Only calculates allSchemas once

* Reduces iteration through allSchemas from 2x to 1x

* Removes some getKey invocations

* Consolidates more getKey usages

* Deletes getKey with one input

* Adds comment

* Updates the definition of required properties, reduces the number of calls to getKey

* Updates getKey to use sourceJsonPath

* Adds class name generation that includes numbered suffixes when needed

* Uses pre order traversal for naming schema classes

* Fixes oneOf/anyOf/allOf type aliases

* Adds and uses schemas.INPUT_BASE_TYPES

* Adds string representation of CodegenKey

* Fixes java tests

* Samples regenerated

* Samples regenerated
spacether added a commit that referenced this pull request Aug 16, 2023
* Writes nested schemas earlier and uses them later

* Refactors order CodegenSchema properties are set in to match the order in getSchemas

* Adjusts ref input to setSchemaLocationInfo

* Tweak improves schema template

* Adds properties classes

* Replaces properties with field

* Uses Schema_()

* Uses dataclass properties

* Adds missing type info

* Updates all_of

* Adds any_of, all_of tuples

* Fixes types definition

* Fixed test_any_type_schema tests

* Fixes dataclass type setting issues

* Fixes simple schema format type

* Adds and uses PatternInfo for pattern schema info, validate_regex changed to validate_pattern

* Fixes not constraint tests

* Adds tuple_to_instance

* Writes out allOf/anyOf/oneOf types

* Updates classproperty decorator

* Adds enum return types

* Fixes type errors in schemas.py

* Adds schema singleton metaclass

* Replaces CodegenServer variables with object schema containing variables in properties

* Generates server variables as an object schema to keep all schemas at the root depth

* Fixes new signatures in servers schemas

* Simplifies Server variables definition

* Uses schema default for server variables

* Adds required vars in server definition

* Fixes classproperty and SchemaBase classes

* Fixes broken configuration tests

* Fixes server docs

* Adds isInlineDefinition

* Adds allOf/anyOf/oneOf/properties jsonPathPiece

* Uses jsonPathPiece in properties/allOf/anyOf/oneOf

* Fixes properties typeddict name

* Templates updated to write allOf/anyOf/oneOf/properties earlier if possible

* generates properties/allOf/anyOf/oneOf before class if possible

* Adds and uses schemas.INPUT_TYPES_ALL_INCL_SCHEMA

* Adds another usage of schemas.INPUT_TYPES_ALL_INCL_SCHEMA

* Changes SchemaBase to SingletonMeta

* Only calculates allSchemas once

* Reduces iteration through allSchemas from 2x to 1x

* Removes some getKey invocations

* Consolidates more getKey usages

* Deletes getKey with one input

* Adds comment

* Updates the definition of required properties, reduces the number of calls to getKey

* Updates getKey to use sourceJsonPath

* Adds class name generation that includes numbered suffixes when needed

* Uses pre order traversal for naming schema classes

* Fixes oneOf/anyOf/allOf type aliases

* Adds and uses schemas.INPUT_BASE_TYPES

* Adds string representation of CodegenKey

* Fixes java tests

* Samples regenerated

* Samples regenerated
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.

None yet

1 participant