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

inline parameter enhance with python-experimental fix #12397

Conversation

spacether
Copy link
Contributor

@spacether spacether commented May 18, 2022

inline parameter enhance with python-experimental fix

This is my version of https://github.com/OpenAPITools/openapi-generator/pull/12369/files
where I am working on fixing python-experimental

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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@spacether spacether marked this pull request as draft May 18, 2022 16:27
@spacether spacether force-pushed the sp_inline-parameter-enhance branch from 24eed44 to 7328ebc Compare May 18, 2022 18:09
@spacether spacether changed the base branch from master to inline-parameter-enhance May 18, 2022 18:10
@@ -4581,9 +4581,14 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
String parameterModelName = null;

if (parameter.getSchema() != null) {
parameterModelName = getParameterDataType(parameter ,parameter.getSchema());
parameterSchema = ModelUtils.getReferencedSchema(openAPI, parameter.getSchema());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changing results means that unaliasSchema is working differently than ModelUtils.getReferencedSchema for these parameter schemas.
Investigate the details of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is happening because if an enum schema is referenced, the schema with the reference is returned. This assumes that the generator generates a typed reference to that enum model.

@wing328 wing328 marked this pull request as ready for review May 19, 2022 02:50
@wing328
Copy link
Member

wing328 commented May 19, 2022

Tested python-experimental locally and all tests passed.

petstore_api/model/whale.py                                                           21      0   100%
petstore_api/model/zebra.py                                                           32      5    84%
petstore_api/models/__init__.py                                                      111    111     0%
petstore_api/rest.py                                                                  81     29    64%
petstore_api/schemas.py                                                             1008    105    90%
petstore_api/signing.py                                                              203    165    19%
------------------------------------------------------------------------------------------------------
TOTAL                                                                               8072   1779    78%

=================== 299 passed, 1 warnings in 10.64 seconds ====================
___________________________________ summary ____________________________________
  py39: commands succeeded
  congratulations :)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  49.921 s
[INFO] Finished at: 2022-05-19T10:49:00+08:00
[INFO] ------------------------------------------------------------------------

@wing328 wing328 merged commit ced1d53 into OpenAPITools:inline-parameter-enhance May 19, 2022
@wing328 wing328 changed the title inline parameter enhance with python-experimental fix [WIP] inline parameter enhance with python-experimental fix May 19, 2022
wing328 added a commit that referenced this pull request May 20, 2022
* better support for inline schema in parameters

* fix parameter model type

* add new method for model

* minor update

* fix isModelWithProperties

* fix is model check

* null check for properties

* inline parameter enhance with python-experimental fix [WIP] (#12397)

* Uses unaliasSchema rather than ModelUtils.getReferencedSchema

* Fixes python-experimental, delays param schema setting

* Samples regenerated

* Adds parameterModelName setting back in

* Samples regenerated

* removes needToSetSchema

* Sets schema differently depending on if inline model resolver is used

* Adds step for getting ref schema

* Samples regen

* fix test

* bug fix for rust generator

Co-authored-by: Justin Black <spacether@users.noreply.github.com>
@wing328 wing328 added this to the 6.0.0 milestone May 20, 2022
@spacether spacether deleted the sp_inline-parameter-enhance branch May 20, 2022 15:41
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