-
Notifications
You must be signed in to change notification settings - Fork 136
Closed
Labels
enhancementFunctionality that has never existed in guardrailFunctionality that has never existed in guardrailscalaBroadly concerning Scala code generation or the generated Scala codeBroadly concerning Scala code generation or the generated Scala codescala-supportPertains to guardrail-scala-supportPertains to guardrail-scala-support
Description
Swagger documents which contain model definitions which use inheritance via the allOf property (as documented here ) fail to generate server/client stubs due to a Match Error as per the stack trace:
`Exception in thread "main" scala.MatchError: io.swagger.models.ComposedModel@99ff0ebf (of class io.swagger.models.ComposedModel)
at com.twilio.swagger.codegen.SwaggerUtil$.modelMetaType(SwaggerUtil.scala:113)
at com.twilio.swagger.codegen.generators.CirceProtocolGenerator$ProtocolSupportTermInterp$.$anonfun$apply$49(CirceProtocolGenerator.scala:279)
at cats.instances.ListInstances$$anon$1.$anonfun$traverse$2(list.scala:73)
at cats.instances.ListInstances$$anon$1.loop$2(list.scala:63)
at cats.instances.ListInstances$$anon$1.$anonfun$foldRight$1(list.scala:63)
at cats.Eval$$anon$11.$anonfun$start$3(Eval.scala:276)
at cats.Eval$.loop$1(Eval.scala:338)
at cats.Eval$.cats$Eval$$evaluate(Eval.scala:372)
at cats.Eval$Defer.value(Eval.scala:258)
at cats.instances.ListInstances$$anon$1.traverse(list.scala:72)
at cats.instances.ListInstances$$anon$1.traverse(list.scala:12)
at cats.Traverse$Ops.traverse(Traverse.scala:19)
at cats.Traverse$Ops.traverse$(Traverse.scala:19)
at cats.Traverse$ToTraverseOps$$anon$3.traverse(Traverse.scala:19)
at com.twilio.swagger.codegen.generators.CirceProtocolGenerator$ProtocolSupportTermInterp$.apply(CirceProtocolGenerator.scala:275)
at com.twilio.swagger.codegen.generators.CirceProtocolGenerator$ProtocolSupportTermInterp$.apply(CirceProtocolGenerator.scala:271)
at cats.data.EitherK.$anonfun$fold$1(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:189)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.data.EitherK.$anonfun$fold$2(EitherK.scala:87)
at scala.util.Either.fold(Either.scala:188)
at cats.data.EitherK.fold(EitherK.scala:87)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at cats.arrow.FunctionK$$anon$2.apply(FunctionK.scala:47)
at com.twilio.swagger.codegen.generators.AkkaHttp$.apply(AkkaHttp.scala:24)
at com.twilio.swagger.codegen.generators.AkkaHttp$.apply(AkkaHttp.scala:14)
at cats.free.Free.$anonfun$foldMap$1(Free.scala:155)
at cats.data.EitherTMonad.$anonfun$tailRecM$1(EitherT.scala:581)
at cats.data.WriterTFlatMap1.step$1(WriterT.scala:329)
at cats.data.WriterTFlatMap1.$anonfun$tailRecM$2(WriterT.scala:340)
at cats.package$$anon$1.tailRecM(package.scala:42)
at cats.data.WriterTFlatMap1.tailRecM(WriterT.scala:340)
at cats.data.WriterTFlatMap1.tailRecM$(WriterT.scala:326)
at cats.data.WriterTInstances3$$anon$4.tailRecM(WriterT.scala:185)
at cats.data.WriterTInstances3$$anon$4.tailRecM(WriterT.scala:185)
at cats.data.EitherTMonad.tailRecM(EitherT.scala:581)
at cats.data.EitherTMonad.tailRecM$(EitherT.scala:580)
at cats.data.EitherTInstances1$$anon$1.tailRecM(EitherT.scala:507)
at cats.data.EitherTInstances1$$anon$1.tailRecM(EitherT.scala:507)
at cats.free.Free.foldMap(Free.scala:153)
at cats.free.Free.$anonfun$foldMap$1(Free.scala:156)
at cats.data.EitherTMonad.$anonfun$tailRecM$1(EitherT.scala:581)
at cats.data.WriterTFlatMap1.step$1(WriterT.scala:329)
at cats.data.WriterTFlatMap1.$anonfun$tailRecM$2(WriterT.scala:340)
at cats.package$$anon$1.tailRecM(package.scala:42)
at cats.data.WriterTFlatMap1.tailRecM(WriterT.scala:340)
at cats.data.WriterTFlatMap1.tailRecM$(WriterT.scala:326)
at cats.data.WriterTInstances3$$anon$4.tailRecM(WriterT.scala:185)
at cats.data.WriterTInstances3$$anon$4.tailRecM(WriterT.scala:185)
at cats.data.EitherTMonad.tailRecM(EitherT.scala:581)
at cats.data.EitherTMonad.tailRecM$(EitherT.scala:580)
at cats.data.EitherTInstances1$$anon$1.tailRecM(EitherT.scala:507)
at cats.data.EitherTInstances1$$anon$1.tailRecM(EitherT.scala:507)
at cats.free.Free.foldMap(Free.scala:153)
at com.twilio.swagger.codegen.core.CoreTermInterp$.$anonfun$apply$36(CoreInterp.scala:98)
at com.twilio.swagger.codegen.ReadSwagger$.$anonfun$unsafeReadSwagger$3(ReadSwagger.scala:16)
at scala.Option.map(Option.scala:146)
at com.twilio.swagger.codegen.ReadSwagger$.$anonfun$unsafeReadSwagger$2(ReadSwagger.scala:15)
at scala.Option.flatMap(Option.scala:171)
at com.twilio.swagger.codegen.ReadSwagger$.unsafeReadSwagger(ReadSwagger.scala:14)
at com.twilio.swagger.codegen.CLICommon$.$anonfun$run$8(CLI.scala:63)
at scala.collection.immutable.List.map(List.scala:283)
at com.twilio.swagger.codegen.CLICommon$.run(CLI.scala:62)
at com.twilio.swagger.codegen.CLICommon.main(CLI.scala:114)
at com.twilio.swagger.codegen.CLICommon.main$(CLI.scala:113)
at com.twilio.swagger.codegen.CLI$.main(CLI.scala:118)
at com.twilio.swagger.codegen.CLI.main(CLI.scala)`
A sample swagger document to reproduce this issue is attached:
swagger: '2.0'
info:
title: Parsing Error Sample
version: 1.0.0
paths:
/pet/{name}:
get:
parameters:
- $ref: '#/parameters/PetNamePathParam'
responses:
200:
description: Return the details about the pet
schema:
$ref: '#/definitions/Pet'
parameters:
PetNamePathParam:
name: name
description: Unique name of the pet
in: path
type: string
required: true
definitions:
Pet:
type: object
discriminator: petType
properties:
name:
type: string
petType:
type: string
required:
- name
- petType
Cat:
description: A representation of a cat
allOf:
- $ref: '#/definitions/Pet'
- type: object
properties:
huntingSkill:
type: string
description: The measured skill for hunting
default: lazy
enum:
- clueless
- lazy
- adventurous
- aggressive
required:
- huntingSkill
Dog:
description: A representation of a dog
allOf:
- $ref: '#/definitions/Pet'
- type: object
properties:
packSize:
type: integer
format: int32
description: the size of the pack the dog is from
default: 0
minimum: 0
required:
- packSize
It looks like the swagger ComposedModel is not supported at the moment. Are there plans to support model definitions that use inheritance?
metasim
Metadata
Metadata
Assignees
Labels
enhancementFunctionality that has never existed in guardrailFunctionality that has never existed in guardrailscalaBroadly concerning Scala code generation or the generated Scala codeBroadly concerning Scala code generation or the generated Scala codescala-supportPertains to guardrail-scala-supportPertains to guardrail-scala-support