[BUG][typescript-axios] missing discriminator#5263
[BUG][typescript-axios] missing discriminator#5263cervotoc wants to merge 1 commit intoOpenAPITools:masterfrom
Conversation
|
Looks like this change would put the discriminator property twice in the generated interface, if the property is explicitly listed in api spec. This is the case in the examples provided in OAS3, e.g. |
|
Shouldn't a fix involve adding a missing implicit discriminator into allProps in DefaultCodegen instead? And only in a case when it is missing indeed. |
|
@wing328 can you help here? |
|
Ok, I agree. But when I add the discriminator as a property, the server side (openapi generator: spring) adds that property to class and I don't want that. I just want an annotation for discriminator |
|
@cervotoc I see. However, in TS you're emitting it as a regular model property. So there must be some flag in the model determining whether we need to add the discriminator as a new property into the generated model or not. Or just add this unconditionally in the Typescript Client (not in the default codegen, as it would break the existing logic for java and probably something else). The problem is that having the discriminator as a model property in api-spec is a totally valid use case, and is demonstrated in many examples in OAS2 and OAS3. Hence we must make sure the codegen still generates valid typescript code for this case - as well as for your case with no explicit property for discriminator. |
I'll take a look later this week. |
|
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
|
@amakhrov what do you suggest to do here? |
|
@macjohnny I could imagine having additional logic in
|
|
@cervotoc @amakhrov What is the status of this? We are hitting this exact problem. The inheritance support of the typescript-axios generator is not really complete. In addition to the generation of the discriminator property in the interface, it would be necessary to automatically set it to the interfaces name. How have you since solved this? I also tried it with const, but it does not work correctly either: |
Extended musatche template to include generating of discriminator.
PR checklist
./bin/(or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.shif updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).master,4.3.x,5.0.x. Default:master.fixes #5262
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02)