guardrail-dev / guardrail

Principled code generation from OpenAPI specifications
https://guardrail.dev
MIT License
525 stars 132 forks source link

Capitalized operation names in swagger files result in source generation failure #416

Closed dmnava closed 4 years ago

dmnava commented 5 years ago

It looks like a combination of an operationName capitalized and a body parameter results in an exception during code generation, at least with akka-http generator. E.g:

    put:
      operationId: GetSinkConfig
      x-jvm-package: server
      x-tracing-label: "TestScalaServiceKafka:set-sink-endpoint"
      consumes:
        - application/json
      parameters:
        - name: conf
          in: body
          schema:
            $ref: "#/definitions/SinkConfiguration"
          required: true

results in the following exception:

[ERROR] Failed to generate client
org.scalameta.invariants.InvariantFailedException: invariant failed:
when verifying parentCheckOk.&&(org.scalameta.`package`.debug(this, parentPrefix, destination))
found that parentCheckOk is false
where PatVarImpl = GetSinkConfigDecoder
where destination = lhs
where parentCheckOk = false
where parentPrefix = Pat.Typed
where this = GetSinkConfigDecoder
    at org.scalameta.invariants.InvariantFailedException$.raise (Exceptions.scala:15)
    at scala.meta.Pat$Var$PatVarImpl.checkParent$9 (Trees.scala:188)
    at scala.meta.Pat$Var$PatVarImpl.privateCopy (Trees.scala:191)
    at scala.meta.Pat$Typed$.internal$170 (Trees.scala:214)
    at scala.meta.Pat$Typed$.apply (Trees.scala:214)
    at com.twilio.guardrail.generators.AkkaHttpServerGenerator$ServerTermInterp$.$anonfun$generateDecoders$1 (AkkaHttpServerGenerator.scala:796)
    at scala.collection.immutable.List.flatMap (List.scala:338)
    at com.twilio.guardrail.generators.AkkaHttpServerGenerator$ServerTermInterp$.generateDecoders (AkkaHttpServerGenerator.scala:791)
    at com.twilio.guardrail.generators.AkkaHttpServerGenerator$ServerTermInterp$.generateCodecs (AkkaHttpServerGenerator.scala:788)
    at com.twilio.guardrail.generators.AkkaHttpServerGenerator$ServerTermInterp$.$anonfun$generateRoute$25 (AkkaHttpServerGenerator.scala:773)
    at cats.syntax.EitherOps$.bimap$extension (either.scala:128)
    at cats.data.EitherT.$anonfun$bimap$1 (EitherT.scala:76)
    at cats.Monad.$anonfun$map$1 (Monad.scala:16)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateTMonad.$anonfun$tailRecM$2 (IndexedStateT.scala:376)
    at cats.package$$anon$1.tailRecM (package.scala:42)
    at cats.data.IndexedStateTMonad.$anonfun$tailRecM$1 (IndexedStateT.scala:375)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateTMonad.$anonfun$tailRecM$2 (IndexedStateT.scala:376)
    at cats.package$$anon$1.tailRecM (package.scala:42)
    at cats.data.IndexedStateTMonad.$anonfun$tailRecM$1 (IndexedStateT.scala:375)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.$anonfun$flatMap$3 (IndexedStateT.scala:27)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.$anonfun$flatMap$2 (IndexedStateT.scala:26)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at scala.Function1.$anonfun$andThen$1 (Function1.scala:57)
    at cats.data.AndThen.runLoop (AndThen.scala:101)
    at cats.data.AndThen.apply (AndThen.scala:69)
    at cats.data.IndexedStateT.$anonfun$run$1 (IndexedStateT.scala:66)
    at cats.package$$anon$1.flatMap (package.scala:40)
    at cats.data.IndexedStateT.run (IndexedStateT.scala:66)
    at cats.data.IndexedStateT.runEmpty (IndexedStateT.scala:83)
    at com.twilio.guardrail.AbstractGuardrailCodegenMojo.guardrailTask (AbstractGuardrailCodegenMojo.scala:182)
    at com.twilio.guardrail.AbstractGuardrailCodegenMojo.execute (AbstractGuardrailCodegenMojo.scala:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
blast-hardcheese commented 4 years ago

Oh, already resolved, 🎉