Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #701 from apiaryio/kylef/686
Browse files Browse the repository at this point in the history
Fix "fixed" type attribute not inheriting for empty objects
  • Loading branch information
tjanc authored May 20, 2019
2 parents 494176b + 62e9507 commit 045fbe1
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Drafter Changelog

## Master

### Bug Fixes

* The `fixed` type attribute now inherits to empty objects. This regression was
introduced in 4.0.0-pre.1.

## 4.0.0-pre.5 (2019-05-07)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion src/refract/ElementUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ bool refract::inheritsFixed(const IElement& e)

bool refract::inheritsFixed(const ObjectElement& e)
{
return definesValue(e);
return true;
}

bool refract::inheritsFixed(const ArrayElement& e)
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/schema/issue-686.apib
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# GET /

+ Response 200 (application/json)
+ Attributes
+ result (object, fixed)
+ obj_member (object)
184 changes: 184 additions & 0 deletions test/fixtures/schema/issue-686.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"element": "parseResult",
"content": [
{
"element": "category",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "api"
}
]
},
"title": {
"element": "string",
"content": ""
}
},
"content": [
{
"element": "resource",
"meta": {
"title": {
"element": "string",
"content": ""
}
},
"attributes": {
"href": {
"element": "string",
"content": "/"
}
},
"content": [
{
"element": "transition",
"meta": {
"title": {
"element": "string",
"content": ""
}
},
"content": [
{
"element": "httpTransaction",
"content": [
{
"element": "httpRequest",
"attributes": {
"method": {
"element": "string",
"content": "GET"
}
},
"content": []
},
{
"element": "httpResponse",
"attributes": {
"statusCode": {
"element": "string",
"content": "200"
},
"headers": {
"element": "httpHeaders",
"content": [
{
"element": "member",
"content": {
"key": {
"element": "string",
"content": "Content-Type"
},
"value": {
"element": "string",
"content": "application/json"
}
}
}
]
}
},
"content": [
{
"element": "dataStructure",
"content": {
"element": "object",
"content": [
{
"element": "member",
"attributes": {
"typeAttributes": {
"element": "array",
"content": [
{
"element": "string",
"content": "fixed"
}
]
}
},
"content": {
"key": {
"element": "string",
"content": "result"
},
"value": {
"element": "object",
"content": [
{
"element": "member",
"content": {
"key": {
"element": "string",
"content": "obj_member"
},
"value": {
"element": "object"
}
}
}
]
}
}
}
]
}
},
{
"element": "asset",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "messageBody"
}
]
}
},
"attributes": {
"contentType": {
"element": "string",
"content": "application/json"
}
},
"content": "{\n \"result\": {\n \"obj_member\": {}\n }\n}"
},
{
"element": "asset",
"meta": {
"classes": {
"element": "array",
"content": [
{
"element": "string",
"content": "messageBodySchema"
}
]
}
},
"attributes": {
"contentType": {
"element": "string",
"content": "application/schema+json"
}
},
"content": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"type\": \"object\",\n \"properties\": {\n \"result\": {\n \"type\": \"object\",\n \"properties\": {\n \"obj_member\": {\n \"type\": \"object\",\n \"additionalProperties\": false\n }\n },\n \"required\": [\n \"obj_member\"\n ],\n \"additionalProperties\": false\n }\n }\n}"
}
]
}
]
}
]
}
]
}
]
}
]
}
1 change: 1 addition & 0 deletions test/test-SchemaTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ TEST_REFRACT("schema", "one-of-complex");
TEST_REFRACT("schema", "one-of-properties");

TEST_REFRACT("schema", "issue-493-multiple-same-required");
TEST_REFRACT("schema", "issue-686");

0 comments on commit 045fbe1

Please sign in to comment.