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

[typescript] allOf fails with chained inheritance #13417

Open
5 tasks done
MattiasMartens opened this issue Sep 14, 2022 · 6 comments
Open
5 tasks done

[typescript] allOf fails with chained inheritance #13417

MattiasMartens opened this issue Sep 14, 2022 · 6 comments

Comments

@MattiasMartens
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

Using openapigenerator 6.0.1, with generator "typescript".

If a spec uses allOf to specify an inheritance chain, the child in the inheritance chain will have its own properties and the properties of its most distant parent, but not the properties of its closest parent.

In the provided example, the instance of class Child would have Child.ChildAttribute and Child.GrandparentAttribute but not Child.ParentAttribute.

openapi-generator version

6.0.1

OpenAPI declaration file content or url

https://gist.github.com/MattiasMartens/49415a0fe5c3922500424d61c5a3c97a

Related issues/PRs

First raised in #927.

@bk-one
Copy link

bk-one commented Apr 19, 2023

+1

@jbezuk
Copy link

jbezuk commented May 23, 2023

I think this thread may be related: #10125

From my point of view, the workaround options are: a) use discriminators on all inherited types, or b) revert to v4.3.1 where inheritance was still supported without discriminators

though personally I agree with others in that thread stating that discriminators should not really be required in this use case.

@wing328
Copy link
Member

wing328 commented May 24, 2023

We've added a rule REF_AS_PARENT_IN_ALLOF in OpenAPI Normalizer to handle such case: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

Please give it a try when you've time.

@Hiller
Copy link

Hiller commented Jun 2, 2023

We've added a rule REF_AS_PARENT_IN_ALLOF in OpenAPI Normalizer to handle such case: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md#openapi-normalizer

Please give it a try when you've time.

doesn't work with typescript-angular.
command is java -jar 6.6.0.jar generate -i swagger.json -g typescript-angular -o module --openapi-normalizer REF_AS_PARENT_IN_ALLOF=true --additional-properties=useSingleRequestParameter=true

you can put anything for normalizer options without a singly warn from it. Seems like normalizer is not applied at all

@Silverium
Copy link

My team also has issues with the allOf operator. For us it's generating empty interfaces! So something like

paths:
  /cobrand/v1/public/cobrands:
    get:
      allOf:
        - summary: Get cobrands...
        - description: User Session identifier ...

ends up being an ugly and empty get:

  "/cobrand/v1/public/cobrands": {
    get: {
    };
  };

@PetrusHahol
Copy link

How can I set up REF_AS_PARENT_IN_ALLOF=true in my pom.xml for plugin configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants