mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
Added some new getters to the index
Also added map conversion utilities based on reported vacuum error https://github.com/daveshanley/vacuum/issues/417 also prevented the bundler from inlining root references. Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
@@ -56,6 +56,11 @@ func TestSpecIndex_GetCache(t *testing.T) {
|
||||
loaded, ok = extCache.Load("test2")
|
||||
assert.Nil(t, loaded)
|
||||
assert.False(t, ok)
|
||||
|
||||
assert.Len(t, index.GetIgnoredPolymorphicCircularReferences(), 0)
|
||||
assert.Len(t, index.GetIgnoredArrayCircularReferences(), 0)
|
||||
assert.Equal(t, len(index.GetRawReferencesSequenced()), 42)
|
||||
assert.Equal(t, len(index.GetNodeMap()), 824)
|
||||
}
|
||||
|
||||
func TestSpecIndex_ExtractRefsStripe(t *testing.T) {
|
||||
@@ -1535,3 +1540,77 @@ paths:
|
||||
assert.Equal(t, "$.paths['/test2'].put", paths["/test2"]["put"].Path)
|
||||
assert.Equal(t, 22, paths["/test2"]["put"].ParentNode.Line)
|
||||
}
|
||||
|
||||
func TestSpecIndex_TestInlineSchemaPaths(t *testing.T) {
|
||||
|
||||
yml := `openapi: 3.1.0
|
||||
info:
|
||||
title: Test
|
||||
version: 0.0.1
|
||||
servers:
|
||||
- url: http://localhost:35123
|
||||
paths:
|
||||
/test:
|
||||
get:
|
||||
operationId: TestSomething
|
||||
parameters:
|
||||
- name: test
|
||||
in: query
|
||||
description: test param for duplicate inline schema
|
||||
required: false
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
'5XX':
|
||||
description: test response for slightly different inline schema
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- code
|
||||
- messages
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
messages:
|
||||
type: string
|
||||
default:
|
||||
description: test response for duplicate inline schema
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
required:
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
message:
|
||||
type: string`
|
||||
|
||||
var rootNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(yml), &rootNode)
|
||||
|
||||
idx := NewSpecIndexWithConfig(&rootNode, CreateOpenAPIIndexConfig())
|
||||
|
||||
schemas := idx.GetAllInlineSchemas()
|
||||
assert.Equal(t, "$.paths['/test'].get.parameters.schema", schemas[0].Path)
|
||||
assert.Equal(t, "$.paths['/test'].get.parameters.schema.properties.code", schemas[1].Path)
|
||||
assert.Equal(t, "$.paths['/test'].get.parameters.schema.properties.message", schemas[2].Path)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user