panic: runtime error: index out of range
Opened this issue · 0 comments
DavidBiesack commented
I downloaded the latest and ran it on an openapi 2.0 spec file
./dapperdox -spec-dir=/tmp/products -log-level=trace
This failed with an error:
2018/05/09 17:36:40 FQNS: [_error _embedded items[] _links]
2018/05/09 17:36:40 CHECK schema type and items
2018/05/09 17:36:40 Got an object, so slicing _links from resourceFQNS leaving [_error _embedded items[] _links]
2018/05/09 17:36:40 Create resource _links [Links]
2018/05/09 17:36:40 Call compileproperties...
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/dapperdox/dapperdox/spec.(*APISpecification).compileproperties(0xc420322300, 0xc42175fb00, 0xc421f0c0d0, 0xc42009b080, 0xc420ddd0b6, 0x6, 0xc421b921f8, 0xc420b80810, 0xc421ca3280, 0x4, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1247 +0x4aa
github.com/dapperdox/dapperdox/spec.(*APISpecification).resourceFromSchema(0xc420322300, 0xc42175fb00, 0xc42009b080, 0xc421ca3280, 0x4, 0x4, 0x0, 0xc4201eef01, 0xc421ca3280, 0x4)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1215 +0x1126
github.com/dapperdox/dapperdox/spec.(*APISpecification).processProperty(0xc420322300, 0xc42175fb00, 0xc420ddd0b6, 0x6, 0xc4220001a0, 0xc42009b080, 0xc4215e2009, 0x7, 0xc421b92b38, 0xc421415230, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1263 +0x1d4
github.com/dapperdox/dapperdox/spec.(*APISpecification).compileproperties(0xc420322300, 0xc42201a900, 0xc4220001a0, 0xc42009b080, 0xc4215e2009, 0x7, 0xc421b92b38, 0xc421415230, 0xc42165a060, 0x2, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1239 +0x294
github.com/dapperdox/dapperdox/spec.(*APISpecification).resourceFromSchema(0xc420322300, 0xc421177b00, 0xc42009b080, 0xc421ca23c0, 0x3, 0x4, 0x0, 0xc421b92c01, 0xc421ca23c0, 0x3)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1218 +0x1212
github.com/dapperdox/dapperdox/spec.(*APISpecification).processProperty(0xc420322300, 0xc421177b00, 0xc421cef660, 0x5, 0xc422078410, 0xc42009b080, 0xc421d06130, 0x9, 0xc421b93478, 0xc4213a39e0, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1263 +0x1d4
github.com/dapperdox/dapperdox/spec.(*APISpecification).compileproperties(0xc420322300, 0xc4216ec000, 0xc422078410, 0xc42009b080, 0xc421d06130, 0x9, 0xc421b93478, 0xc4213a39e0, 0xc4216423a0, 0x1, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1239 +0x294
github.com/dapperdox/dapperdox/spec.(*APISpecification).resourceFromSchema(0xc420322300, 0xc4216ec000, 0xc42009b080, 0xc421460f20, 0x2, 0x2, 0x0, 0xc421554601, 0xc421460f20, 0x2)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1215 +0x1126
github.com/dapperdox/dapperdox/spec.(*APISpecification).processProperty(0xc420322300, 0xc4216ec000, 0xc421d06130, 0x9, 0xc42190d450, 0xc42009b080, 0xc421d2cc96, 0x6, 0xc421b93db8, 0xc42160f680, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1263 +0x1d4
github.com/dapperdox/dapperdox/spec.(*APISpecification).compileproperties(0xc420322300, 0xc42201a000, 0xc42190d450, 0xc42009b080, 0xc421d2cc96, 0x6, 0xc421b93db8, 0xc42160f680, 0x180ab90, 0x0, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1239 +0x294
github.com/dapperdox/dapperdox/spec.(*APISpecification).resourceFromSchema(0xc420322300, 0xc421ae5680, 0xc42009b080, 0xc421809490, 0x1, 0x1, 0x0, 0xc4212d2d00, 0xc421809490, 0x1)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1218 +0x1212
github.com/dapperdox/dapperdox/spec.(*APISpecification).processProperty(0xc420322300, 0xc421ae5680, 0xc421d2cc96, 0x6, 0xc421abfd40, 0xc42009b080, 0xc42157a108, 0x8, 0xc421b946f8, 0xc4219c77a0, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1263 +0x1d4
github.com/dapperdox/dapperdox/spec.(*APISpecification).compileproperties(0xc420322300, 0xc421569600, 0xc421abfd40, 0xc42009b080, 0xc42157a108, 0x8, 0xc421b946f8, 0xc4219c77a0, 0x0, 0x0, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1239 +0x294
github.com/dapperdox/dapperdox/spec.(*APISpecification).resourceFromSchema(0xc420322300, 0xc4201a9d40, 0xc42009b080, 0x0, 0x0, 0x0, 0x0, 0xb33d44b47f37c880, 0x0, 0xc421b2e7d8)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:1218 +0x1212
github.com/dapperdox/dapperdox/spec.(*APISpecification).buildResponse(0xc420322300, 0xc421b94b00, 0xc42009b080, 0x1566da7, 0x6, 0x0)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:786 +0x305
github.com/dapperdox/dapperdox/spec.(*APISpecification).processMethod(0xc420322300, 0xc4201ee370, 0xc421b95918, 0xc42024c9a0, 0xc4216b8620, 0xa, 0x15648b2, 0x3, 0x1566da7, 0x6, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:754 +0xcc7
github.com/dapperdox/dapperdox/spec.(*APISpecification).getMethod(0xc420322300, 0x0, 0xc42046cb40, 0x22, 0xc4201c0798, 0x3, 0x0, 0xc4201ee370, 0xc4201ee3c0, 0x1566da7, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:530 +0x387
github.com/dapperdox/dapperdox/spec.(*APISpecification).getMethods(0xc420322300, 0x0, 0xc42046cb40, 0x22, 0xc4201c0798, 0x3, 0x0, 0xc4201ee370, 0xc4201ee3c0, 0xc421b95918, ...)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:498 +0xe4
github.com/dapperdox/dapperdox/spec.(*APISpecification).Load(0xc420322300, 0x156c1ed, 0xd, 0x156d158, 0xe, 0x1a00, 0x69)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:427 +0xc22
github.com/dapperdox/dapperdox/spec.LoadSpecifications(0x156d158, 0xe, 0xc42039b101, 0xc42039b120, 0xc42039b070)
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/spec/spec.go:281 +0x258
main.main()
/Users/csmith1/src/go/src/github.com/dapperdox/dapperdox/main.go:97 +0x5fc
From this, it looks like it is processing the Links
schema, but that is used heavily in our
API (many schema extend from a base schema that defines _links
)
I can't share the spec here (proprietary, sorry) however it uses HAL and the schemas try to define
a _links
object which has type Links
, which is a map of string -> Link
thing:
...
properties:
_links:
$ref: '#/definitions/links'
links:
title: Links
description: >-
An optional map of links, mapping each link relation to a link object.
This model defines the `_links` object of HAL representations.
type: object
additionalProperties:
$ref: '#/definitions/link'
link:
title: Link
description: >-
Describes a hypermedia link within a `_links` object in [HAL
links](https://tools.ietf.org/html/draft-kelly-json-hal-08#section-5)
representations.
required:
- href
properties:
href:
type: string
format: uri
description: >-
The URI or URI template for the resource/operation this link refers
to.
.... etc
Tips on diagnosing this (I don't have much familiarity with go and how to build/debug this locally)