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

Commit cdeae4b

Browse files
authored
Fix for #668 and #669. These add defaults for Files and Arrays. (#670)
1 parent f5c3579 commit cdeae4b

File tree

3 files changed

+261
-0
lines changed

3 files changed

+261
-0
lines changed

raml-parser-2/src/main/java/org/raml/v2/internal/impl/v10/rules/TypeDefaultValue.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public Node getDefaultValue(Node parent)
4040
{
4141
return new NativeTypeExpressionNode(TypeId.OBJECT.getType());
4242
}
43+
if (parent.get("items") != null)
44+
{
45+
return new NativeTypeExpressionNode(TypeId.ARRAY.getType());
46+
}
47+
if (parent.get("fileTypes") != null)
48+
{
49+
return new NativeTypeExpressionNode(TypeId.FILE.getType());
50+
}
51+
4352
return new OverridableNativeTypeExpressionNode(defaultType.getType());
4453
}
4554
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#%RAML 1.0
2+
# Adding more tests for defaults based on facets (Arrays and Files...add more as required)
3+
title: My API
4+
mediaType: application/json
5+
6+
types:
7+
someArray:
8+
items:
9+
properties:
10+
Foo: integer
11+
Bar: string
12+
fireworks:
13+
description: This is a new DataType
14+
fileTypes:
15+
- image/gif
16+
17+
/resource:
18+
post:
19+
body:
20+
application/json:
21+
type: array
22+
items: integer
23+
example: [1, 2]
24+
25+
/other_resource:
26+
post:
27+
body:
28+
application/json:
29+
items:
30+
properties:
31+
Foo: integer
32+
Bar: string
33+
example:
34+
[{"Foo": 1, "Bar": "Qux"}]

0 commit comments

Comments
 (0)