From d762c5ad1f94f81135d1a6d5d681b63095f2ab26 Mon Sep 17 00:00:00 2001 From: Jiri Kratochvil Date: Wed, 25 May 2016 14:57:46 +0200 Subject: [PATCH] Fix #328 --- src/NamedTypesRegistry.cc | 2 +- test/fixtures/render/issue-328-1.apib | 6 ++ test/fixtures/render/issue-328-1.ast.json | 86 ++++++++++++++++++++++ test/fixtures/render/issue-328-2.apib | 11 +++ test/fixtures/render/issue-328-2.ast.json | 90 +++++++++++++++++++++++ test/test-RenderTest.cc | 3 + 6 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/render/issue-328-1.apib create mode 100644 test/fixtures/render/issue-328-1.ast.json create mode 100644 test/fixtures/render/issue-328-2.apib create mode 100644 test/fixtures/render/issue-328-2.ast.json diff --git a/src/NamedTypesRegistry.cc b/src/NamedTypesRegistry.cc index f2e6976b3..02a320ce2 100644 --- a/src/NamedTypesRegistry.cc +++ b/src/NamedTypesRegistry.cc @@ -289,7 +289,7 @@ namespace drafter { } InheritanceMap::const_iterator i = childToParent.find(s); - if (i == childToParent.end()) { + if (i == childToParent.end() || (s == i->second)) { return mson::UndefinedTypeName; } diff --git a/test/fixtures/render/issue-328-1.apib b/test/fixtures/render/issue-328-1.apib new file mode 100644 index 000000000..6a3039d48 --- /dev/null +++ b/test/fixtures/render/issue-328-1.apib @@ -0,0 +1,6 @@ +## C [/c] + +### Add C([POST]) + ++ Attributes (C) + diff --git a/test/fixtures/render/issue-328-1.ast.json b/test/fixtures/render/issue-328-1.ast.json new file mode 100644 index 000000000..b5e9b6445 --- /dev/null +++ b/test/fixtures/render/issue-328-1.ast.json @@ -0,0 +1,86 @@ +{ + "_version": "2.2", + "ast": { + "_version": "4.0", + "metadata": [], + "name": "", + "description": "", + "element": "category", + "resourceGroups": [ + { + "name": "", + "description": "", + "resources": [ + { + "element": "resource", + "name": "C", + "description": "### Add C([POST])\n\n", + "uriTemplate": "/c", + "model": {}, + "parameters": [], + "actions": [], + "content": [ + { + "element": "dataStructure", + "content": [ + { + "element": "C", + "meta": { + "id": "C" + } + } + ] + } + ] + } + ] + } + ], + "content": [ + { + "element": "category", + "content": [ + { + "element": "resource", + "name": "C", + "description": "### Add C([POST])\n\n", + "uriTemplate": "/c", + "model": {}, + "parameters": [], + "actions": [], + "content": [ + { + "element": "dataStructure", + "content": [ + { + "element": "C", + "meta": { + "id": "C" + } + } + ] + } + ] + } + ] + } + ] + }, + "error": { + "code": 0, + "message": "", + "location": [] + }, + "warnings": [ + { + "code": 8, + "message": "unable to find the symbol `C` in the list of named types", + "location": [ + { + "index": 32, + "length": 15 + } + ] + } + ] +} diff --git a/test/fixtures/render/issue-328-2.apib b/test/fixtures/render/issue-328-2.apib new file mode 100644 index 000000000..d6885d5cd --- /dev/null +++ b/test/fixtures/render/issue-328-2.apib @@ -0,0 +1,11 @@ +# API + +## C [/c] + +### Add C(`[POST ++ Attributes (C) + +## Data Structures + +## C (object) + diff --git a/test/fixtures/render/issue-328-2.ast.json b/test/fixtures/render/issue-328-2.ast.json new file mode 100644 index 000000000..e921a3343 --- /dev/null +++ b/test/fixtures/render/issue-328-2.ast.json @@ -0,0 +1,90 @@ +{ + "_version": "2.2", + "ast": { + "_version": "4.0", + "metadata": [], + "name": "API", + "description": "", + "element": "category", + "resourceGroups": [ + { + "name": "", + "description": "", + "resources": [ + { + "element": "resource", + "name": "C", + "description": "### Add C(`[POST\n", + "uriTemplate": "/c", + "model": {}, + "parameters": [], + "actions": [], + "content": [ + { + "element": "dataStructure", + "content": [ + { + "element": "C", + "meta": { + "id": "C" + } + } + ] + } + ] + } + ] + } + ], + "content": [ + { + "element": "category", + "content": [ + { + "element": "resource", + "name": "C", + "description": "### Add C(`[POST\n", + "uriTemplate": "/c", + "model": {}, + "parameters": [], + "actions": [], + "content": [ + { + "element": "dataStructure", + "content": [ + { + "element": "C", + "meta": { + "id": "C" + } + } + ] + } + ] + } + ] + }, + { + "element": "category", + "content": [] + } + ] + }, + "error": { + "code": 0, + "message": "", + "location": [] + }, + "warnings": [ + { + "code": 2, + "message": "named type with name 'C' already exists", + "location": [ + { + "index": 73, + "length": 15 + } + ] + } + ] +} diff --git a/test/test-RenderTest.cc b/test/test-RenderTest.cc index 8174fd1f8..c3016bf80 100644 --- a/test/test-RenderTest.cc +++ b/test/test-RenderTest.cc @@ -38,3 +38,6 @@ TEST_AST("render", "object-array-string"); TEST_AST("render", "issue-246"); TEST_AST("render", "issue-318"); TEST_AST("render", "issue-312"); + +TEST_AST("render", "issue-328-1"); +TEST_AST("render", "issue-328-2");