Skip to content

Commit

Permalink
Fix for raml-org#668 and raml-org#669. These add defaults for Files a…
Browse files Browse the repository at this point in the history
…nd Arrays. (raml-org#670)
  • Loading branch information
jpbelang authored and juanchib committed Mar 4, 2020
1 parent a58846d commit 5b16d25
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public Node getDefaultValue(Node parent)
{
return new NativeTypeExpressionNode(TypeId.OBJECT.getType());
}
if (parent.get("items") != null)
{
return new NativeTypeExpressionNode(TypeId.ARRAY.getType());
}
if (parent.get("fileTypes") != null)
{
return new NativeTypeExpressionNode(TypeId.FILE.getType());
}

return new OverridableNativeTypeExpressionNode(defaultType.getType());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#%RAML 1.0
# Adding more tests for defaults based on facets (Arrays and Files...add more as required)
title: My API
mediaType: application/json

types:
someArray:
items:
properties:
Foo: integer
Bar: string
fireworks:
description: This is a new DataType
fileTypes:
- image/gif

/resource:
post:
body:
application/json:
type: array
items: integer
example: [1, 2]

/other_resource:
post:
body:
application/json:
items:
properties:
Foo: integer
Bar: string
example:
[{"Foo": 1, "Bar": "Qux"}]
Loading

0 comments on commit 5b16d25

Please sign in to comment.