guardrail-dev / guardrail-dev/guardrail

InvariantFailedException on swagger inheritance

Open
#174 2 comments 0 reactions 0 assignees View on GitHub
bug good first issue help wanted scala
Dominant language
Scala
Stars
541
Forks
138
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have a swagger spec where the definitions include inheritance like this minimal example:

```yaml
---
swagger: "2.0"
info:
version: "1.0.1"
basePath: "/v1"
paths:
definitions:
A:
type: "object"
B:
allOf:
- $ref: "#/definitions/A"
- type: "object"
C:
allOf:
- $ref: "#/definitions/B"
- type: "object"
```

Running guardrail 0.43.0 with that spec crashes with:

```
Error: Error attempting to process swagger.yaml:

org.scalameta.invariants.InvariantFailedException: invariant failed:
when verifying value.!=(null)
found that value is equal to null
where value = null
at com.twilio.guardrail.generators.CirceProtocolGenerator$PolyProtocolTermInterp$.apply(CirceProtocolGenerator.scala:395)
at com.twilio.guardrail.generators.CirceProtocolGenerator$PolyProtocolTermInterp$.apply(CirceProtocolGenerator.scala:364)
...
at com.twilio.guardrail.generators.AkkaHttp$.apply(AkkaHttp.scala:32)
at com.twilio.guardrail.generators.AkkaHttp$.apply(AkkaHttp.scala:14)
...
at com.twilio.guardrail.core.CoreTermInterp$$anon$1.$anonfun$apply$37(CoreTermInterp.scala:129)
...
at com.twilio.guardrail.ReadSwagger$.readSwagger(ReadSwagger.scala:24)
at com.twilio.guardrail.CLICommon$.$anonfun$run$8(CLI.scala:69)
...
at com.twilio.guardrail.CLICommon$.run(CLI.scala:67)
at com.twilio.guardrail.CLICommon$$anonfun$handleLanguage$1.$anonfun$applyOrElse$1(CLI.scala:128)
at com.twilio.guardrail.CLICommon$$anonfun$handleLanguage$1.$anonfun$applyOrElse$1$adapted(CLI.scala:128)
at com.twilio.guardrail.CLICommon.main(CLI.scala:133)
at com.twilio.guardrail.CLICommon.main$(CLI.scala:131)
at com.twilio.guardrail.CLI$.main(CLI.scala:137)
at com.twilio.guardrail.CLI.main(CLI.scala)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.