mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-09 12:37:49 +00:00
Updated index to count schemas, even if they are refs.
This was brought up in chat, that the expectation is that all schemas are included, refs or not. This update fixes that for the index and adds in a new individual property to count just the references `GetAllReferenceSchemas ` Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
@@ -125,32 +125,33 @@ components:
|
||||
assert.Len(t, index.GetReferenceIndexErrors(), 1)
|
||||
}
|
||||
|
||||
func TestSpecIndex_LocateRemoteDocsWithNoBaseURLSupplied(t *testing.T) {
|
||||
// This test will push the index to do try and locate remote references that use relative references
|
||||
spec := `openapi: 3.0.2
|
||||
info:
|
||||
title: Test
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/test:
|
||||
get:
|
||||
parameters:
|
||||
- $ref: "https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"`
|
||||
|
||||
var rootNode yaml.Node
|
||||
_ = yaml.Unmarshal([]byte(spec), &rootNode)
|
||||
|
||||
c := CreateOpenAPIIndexConfig()
|
||||
index := NewSpecIndexWithConfig(&rootNode, c)
|
||||
|
||||
// extract crs param from index
|
||||
crsParam := index.GetMappedReferences()["https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"]
|
||||
assert.NotNil(t, crsParam)
|
||||
assert.True(t, crsParam.IsRemote)
|
||||
assert.Equal(t, "crs", crsParam.Node.Content[1].Value)
|
||||
assert.Equal(t, "query", crsParam.Node.Content[3].Value)
|
||||
assert.Equal(t, "form", crsParam.Node.Content[9].Value)
|
||||
}
|
||||
// disabled test because remote host is flaky.
|
||||
//func TestSpecIndex_LocateRemoteDocsWithNoBaseURLSupplied(t *testing.T) {
|
||||
// // This test will push the index to do try and locate remote references that use relative references
|
||||
// spec := `openapi: 3.0.2
|
||||
//info:
|
||||
// title: Test
|
||||
// version: 1.0.0
|
||||
//paths:
|
||||
// /test:
|
||||
// get:
|
||||
// parameters:
|
||||
// - $ref: "https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"`
|
||||
//
|
||||
// var rootNode yaml.Node
|
||||
// _ = yaml.Unmarshal([]byte(spec), &rootNode)
|
||||
//
|
||||
// c := CreateOpenAPIIndexConfig()
|
||||
// index := NewSpecIndexWithConfig(&rootNode, c)
|
||||
//
|
||||
// // extract crs param from index
|
||||
// crsParam := index.GetMappedReferences()["https://schemas.opengis.net/ogcapi/features/part2/1.0/openapi/ogcapi-features-2.yaml#/components/parameters/crs"]
|
||||
// assert.NotNil(t, crsParam)
|
||||
// assert.True(t, crsParam.IsRemote)
|
||||
// assert.Equal(t, "crs", crsParam.Node.Content[1].Value)
|
||||
// assert.Equal(t, "query", crsParam.Node.Content[3].Value)
|
||||
// assert.Equal(t, "form", crsParam.Node.Content[9].Value)
|
||||
//}
|
||||
|
||||
func TestSpecIndex_LocateRemoteDocsWithRemoteURLHandler(t *testing.T) {
|
||||
// This test will push the index to do try and locate remote references that use relative references
|
||||
|
||||
Reference in New Issue
Block a user