SwagGen icon indicating copy to clipboard operation
SwagGen copied to clipboard

Illegal Instruction: 4 on valid OAS 3.0

Open dskvr opened this issue 6 years ago • 7 comments

Unfortunately, I have nothing else to report because using --verbose does not result in any additional information. My gut feeling tells me swaggen doesn't account for any types (ie: {}), which are valid OAS 3.0 types.

$ swagger-cli validate swagger/chain.yaml
swagger/chain.yaml is valid
$ swaggen generate swagger/chain.yaml
Illegal Instruction: 4
$ swaggen version
Version: 4.0.0

Update: chain.yaml includes local references, so I tried a bundled/dereferenced version of the same specification with the exact same result.

dskvr avatar Mar 22 '19 11:03 dskvr

Hi @dskvr, thanks for the report. Unfortunately without a an example spec I can’t debug this. If you could put together an example that fails that would be great.

yonaskolb avatar Mar 22 '19 21:03 yonaskolb

Sure thing @yonaskolb, here's a dereferenced version of the specification. bundled-deref.yaml.zip

dskvr avatar Mar 24 '19 09:03 dskvr

Thanks @dskvr. Looks like the issue is the empty security:

security:
  - {}

If that is removed it's all good. That obviously shouldn't crash the parser, and will be fixed, but as a workaround you can just remove that

yonaskolb avatar Mar 24 '19 10:03 yonaskolb

Thanks!

Is there a good way to debug SwagGen on my own?

dskvr avatar Mar 25 '19 11:03 dskvr

To debug in Xcode you can checkout the repo and then

swift package generate-xcodeproj

Then in the swaggen scheme you can add a command line option

generate path/to/spec.yml

And then just run

yonaskolb avatar Mar 25 '19 11:03 yonaskolb

Thanks @yonaskolb!

Sidenote: I got Swaggen to generate, but the serialization logic appears to stop if it hits an anyOf member. In my case, it creates a public var trx with type Trx but Trx does not exist.

The spec I've provided is a pretty extreme case, it trips up serialization of almost every code generator I've come across aside from throwing the json-schemas (models) that make up this OAS spec into quicktype.io. It's entirely possible something is amidst in the spec despite validation (we all know how OAS 3.0 is right now...)

When I've isolated the cause in a way that can be succinctly expressed, I'll open a new issue.

Thanks for your help!

dskvr avatar Mar 25 '19 14:03 dskvr

Reopening this as the crash is still an issue that needs to be fixed

yonaskolb avatar Mar 29 '19 11:03 yonaskolb