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

[Go] Fix "allOf" inherited model properties by embedding parent models #12683

Closed

Conversation

DouglasDwyer
Copy link

This PR addresses issue #10219. The Go client generator does not include properties from allOf dependencies in generated models. This is solved by embedding the parent models into the generated Go structs, making all properties (including inherited ones) available on models. This behavior also more closely matches the Swagger API generator, which handles allOf cases like this by including all of the inherited properties (including parent properties) in the generated models.

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.
  • File the PR against the correct branch: master (6.0.1) (patch release), 6.1.x (breaking changes with fallbacks), 7.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. @antihax @grokify @kemokemo @jirikuncar @ph4r5h4d

antonio-petricca and others added 30 commits May 26, 2022 23:31
* Add authentication for haskell-servant

* Add BearerToken to HaskellServantCodegen.java
* [ocaml] Open Lwt.Infix rather than Lwt

The Lwt module has functions that might shadow parameters, and all the
functions we use from Lwt are in Lwt.Infix too.

    File "src/apis/image_api.ml", line 13, characters 69-72:
    13 |     let uri = Request.maybe_add_query_param uri "all" string_of_bool all in
                                                                              ^^^
    Error: This expression has type 'a t list -> 'a list t
           but an expression was expected of type bool option

* [ocaml] update petstore samples
)

* Migrate annotation.Generated

* Upgrade jakarta.servlet and jakarta.validation

* Prepare pom.xml for spring boot 3

* Introduce spring-boot-3 sample config.

* Create spring-boot-3 sample.

* Introduce useSpringBoot3 cli option.

* Generate Docs

* Add spring milestone repo

* Generate Samples

* Adjust Unit Tests

* Add Spring Boot 3 Support to spring-cloud library

* generate spring cloud 3 sample

* Remove springfox

* Fix typo.

* No longer support SpringFox and Swagger1 with Spring Boot > 3.x

* Generate Docs

* Use Spring Boot 3.0.0-M3

* Generate Samples
The current code is a syntax error in Python 3.

The proposed code works as expected in both Python 2 and Python 3.
* Fixed enum values generation fo 'GraphQL NodeJS Express Server' generator.

* Fixed enarrays generation for 'GraphQL NodeJS Express Server' generator.
…2480)

* + support for enum models & separating mustache templates for enums and generics
+ extract property 'type' and 'default value' from a #ref to an enum model
+ support for `PascalCase` naming convention for PHP generators
+ use a default value for known basic types when they are not nullable
+ use 'null' as default value for nullable types when they do not specify the default value
+ use defined constant path as enum default value when found

* + sample output update

* + change model fields to be public and acessible from outside

* + sample output update

Co-authored-by: Mostafa Aghajani <[email protected]>
…ken since 5.2.0 (OpenAPITools#12239)

* I feel the issue is due to the creation of self._var_name_to_model_instances while doing the deserialization of the data.

Earlier the Python SDK code was using get_var_name_to_model_instances function which was adding var name to model instances that contain it. So <class 'openapi_client.model.stream_options_all_of'> will not part of mapping in self._var_name_to_model_instances for variable name stream_options.

Now with the latest Python SDK code following is the way through which var_name_to_model_instances is created:

    for prop_name in model_args:
        if prop_name not in discarded_args:
            var_name_to_model_instances[prop_name] = [self] + composed_instances
Now as we can see that the var_name_to_model_instances is populated with self and composed_instance which will also contain stream_options_all_of as a composed instance and there will be no check that if stream_options is present in composed_instances or not.

As there is no attribute_mapping found for stream_options in stream_options_all_of, the type for stream_options will be treated as dict for mapping stream_options_all_of as mentioned by @Chekov2k.

So what I suggest is the following code:

    for prop_name in model_args:
        if prop_name not in discarded_args:
           var_name_to_model_instances[prop_name] = [self] + list(
                filter(
                    lambda x: prop_name in x.openapi_types, composed_instances))
This way we can check if the property name is present in that composed instance or not. If it's okay for @spacether I can raise a PR for this.

* [get_item_all_of_bug]
Added samples, test cases to validate all_of schema.

* [getiem_all_of_bug]

Updated docs and samples.

* [getiem_all_of_bug]

Updated test cases, docs and samples.
* add support for all in R client generator

* update samples
* update r doc, tests

* add new files
)

* [typescript-angular] remove outdated angular samples

* [typescript-angular] remove unused sample

* [typescript-angular] remove unused ref

* [typescript-angular] add oneof & provided in any examples

* [typescript-angular] update samples

* [typescirpt-angular] migrate test to angular 12/13

* [typescript-angular] update samples
…s#12459)

* add support text/html

* regenerate samples

* test
* fix addImport method

* add function splitComposedType

* super.addImport

* add docs for splitComposedType

* add docs for splitComposedType
…hod is done with correct arguments (OpenAPITools#12496)

* [Java/Spring] add missing key parameter to put-item method call of super class (OpenAPITools#12494)

* [Java/Spring] add test for missing key parameter to put-item method call of super class (OpenAPITools#12494)
- Also set version for spring maven plugin as it does _not_ work with the milestone version
…PITools#12323)

* Added 'WithHttpInfo Variant' in api_doc template

* Update the samples
ledoyen and others added 27 commits June 15, 2022 15:50
Updated maven plugin to the latest released version 6.0.0
…ols#12599)

* Fix cookies in parameters are always generated as required

* Fix cookies in parameters are always generated as required
Update openapi-generator-cli.jar to the latest 6.0.0 version
* Default enum value and type are seperated by .

* classname is added to enum default property
…12639)

* fix bugs in lambda, add tests for pascalcase

* add tests for empty string to confirm no npe
* fix item reserved words

* add comment

* add log
…enAPITools#12664)

* Make it possible to opt out of JSONEncodable conformance

JSONEncodable is not a native type and does not exist if only models are generated.

* Match file indentation level
* OkHttpClient - fix enum properties in requests

* Has been committed the generated code

Co-authored-by: Mikhail Yartsev <[email protected]>
…s used (OpenAPITools#12594)

* Step to reproduces

* Fix isMap detection for kotlin codegen

Co-authored-by: Eric Durand-Tremblay <[email protected]>
* use rlang as exception in the petstore test

* add errorObject support

* fix method name, use ModelApiRespeonse

* update samples

* update doc

* fix api exception
@DouglasDwyer
Copy link
Author

I submitted the wrong branch. I will reopen with the correct changes

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.