Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 318ed2c

Browse files
committed
Final commit for #678
1 parent 9f0fc1b commit 318ed2c

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

raml-parser-2/src/test/java/org/raml/v2/api/SystemPropertiesTestCase.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.junit.After;
1919
import org.junit.Test;
20+
import org.raml.yagi.framework.grammar.rule.BooleanTypeRule;
2021
import org.raml.yagi.framework.util.DateUtils;
2122

2223
import java.io.File;
@@ -36,6 +37,7 @@ public void clearProperties()
3637
{
3738
clearFailOnWarning();
3839
DateUtils.FOUR_YEARS_VALIDATION = true;
40+
System.clearProperty(BooleanTypeRule.STRICT_BOOLEANS);
3941
// DateUtils.setFormatters();
4042
}
4143

@@ -56,14 +58,30 @@ public void doNotFailOnWarning() throws IOException
5658
assertThat(ramlModelResult.hasErrors(), is(false));
5759
}
5860

61+
@Test
62+
public void failOnString() throws IOException
63+
{
64+
System.setProperty(BooleanTypeRule.STRICT_BOOLEANS, "true");
65+
RamlModelResult ramlModelResult = getStringBoolean();
66+
assertThat(ramlModelResult.hasErrors(), is(true));
67+
assertThat(ramlModelResult.getValidationResults().size(), is(1));
68+
}
69+
70+
@Test
71+
public void doNotFailString() throws IOException
72+
{
73+
RamlModelResult ramlModelResult = getStringBoolean();
74+
assertThat(ramlModelResult.hasErrors(), is(false));
75+
}
76+
5977
private RamlModelResult getJsonSchemaApi()
6078
{
6179
return getApi("src/test/resources/org/raml/v2/api/v10/system-properties/jsonschema-fail-on-warning.raml");
6280
}
6381

64-
private RamlModelResult getDateTimeApi()
82+
private RamlModelResult getStringBoolean()
6583
{
66-
return getApi("src/test/resources/org/raml/v2/api/v10/system-properties/date-only-validation.raml");
84+
return getApi("src/test/resources/org/raml/v2/api/v10/system-properties/string-boolean.raml");
6785
}
6886

6987
private RamlModelResult getApi(String pathname)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#%RAML 1.0
2+
title: Sample API
3+
types:
4+
TestType:
5+
type: object
6+
properties:
7+
count?: integer
8+
flag?: boolean
9+
name?: string
10+
/test:
11+
post:
12+
body:
13+
application/json:
14+
type: TestType
15+
example: |
16+
{ "count": 12, "flag": "true", "name": "Joe" }

yagi/src/main/java/org/raml/yagi/framework/grammar/rule/BooleanTypeRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class BooleanTypeRule extends AbstractTypeRule
3131
{
32-
private static final String STRICT_BOOLEANS = "org.raml.strict_booleans";
32+
public static final String STRICT_BOOLEANS = "org.raml.strict_booleans";
3333

3434
private final static String TRUE = "true";
3535
private final static String FALSE = "false";

0 commit comments

Comments
 (0)