Skip to content

Commit

Permalink
[#9] - Replace double-quotes with single quote to allow using unescap…
Browse files Browse the repository at this point in the history
…ed quotes in validation messages
  • Loading branch information
tfesenko committed Oct 16, 2015
1 parent b4e6ee6 commit f2a852c
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ValidationMessageTest {

@Test
def testMessage_additionalItems_notAllowed() {
var expected = "instance type (integer) does not match any allowed primitive type (allowed: [\"array\"])"
var expected = 'instance type (integer) does not match any allowed primitive type (allowed: ["array"])'

This comment has been minimized.

Copy link
@tedepstein

tedepstein Oct 16, 2015

Collaborator

I think we should remove the word primitive, because this error message is not limited to cases where a primitive type is expected. In this particular case, it's an array.

This comment has been minimized.

Copy link
@tfesenko

tfesenko Jan 13, 2016

Author Member

Fixed

// parameters should contain an array of object
val content = '''
swagger: '2.0'
Expand All @@ -43,7 +43,7 @@ class ValidationMessageTest {

@Test
def testMessage_typeNoMatch() {
var expected = "instance type (integer) does not match any allowed primitive type (allowed: [\"object\"])"
var expected = 'instance type (integer) does not match any allowed primitive type (allowed: ["object"])'

This comment has been minimized.

Copy link
@tedepstein

tedepstein Oct 16, 2015

Collaborator

In this case it's expecting an object, so best to remove primitive.

// responses should contain an object
val content = '''
swagger: '2.0'
Expand All @@ -61,7 +61,7 @@ class ValidationMessageTest {

@Test
def testMessage_notInEnum() {
val expected = "instance value (\"foo\") not found in enum (possible values: [\"http\",\"https\",\"ws\",\"wss\"])"
val expected = 'instance value ("foo") not found in enum (possible values: ["http","https","ws","wss"])'
val content = '''
swagger: '2.0'
info:
Expand All @@ -83,7 +83,7 @@ class ValidationMessageTest {

@Test
def testMessage_oneOf_fail() {
val expected = "instance failed to match exactly one schema (matched 0 out of 2)"
val expected = 'instance failed to match exactly one schema (matched 0 out of 2)'

This comment has been minimized.

Copy link
@tedepstein

tedepstein Oct 16, 2015

Collaborator

Can we follow this by a listing of the allowed schemas? Some cases are straightforward:

  • If the schema is a $ref, the value of the $ref key should be sufficient to describe it.
  • If the schema is a primitive type (even if it has other constraints), the name of the expected type should be sufficient
  • If the schema is an object, we could identify it as such, and list the first few of its properties, starting with required properties.

But there may be other allowable forms of schema that are not as easily described.

This comment has been minimized.

Copy link
@tfesenko

tfesenko Jan 13, 2016

Author Member

This one is covered by #60

val content = '''
swagger: '2.0'
info:
Expand All @@ -102,7 +102,7 @@ class ValidationMessageTest {

@Test
def testMessage_additionalProperties_notAllowed() {
val expected = "object instance has properties which are not allowed by the schema: [\"description\"]"
val expected = 'object instance has properties which are not allowed by the schema: ["description"]'

This comment has been minimized.

Copy link
@tedepstein

tedepstein Oct 16, 2015

Collaborator

Assuming the square-bracketed value is a list of extra property names that were present in the instance, but not permitted by the schema. To be consistent with the other errors, I think we should move this square-bracketed list after the word properties.

This comment has been minimized.

Copy link
@tfesenko

tfesenko Jan 13, 2016

Author Member

Fixed, new message - 'object has properties "description" which are not allowed'

// description should be 2 spaces forward
val content = '''
swagger: '2.0'
Expand Down

0 comments on commit f2a852c

Please sign in to comment.