-
Notifications
You must be signed in to change notification settings - Fork 66
Resource Type Parameter not being properly handled #134
Comments
The underlying library that expands datatypes after it parses the RAML file and before it loads it into Osprey does not support BTW, you might want to define your types:
test:
properties:
test_value: string In the meantime, you'll have to avoid using #%RAML 1.0
title: test
mediaType: application/json
types:
test:
properties:
test_value: string
resourceTypes:
testType:
post:
body:
type: test
/test:
type: testType
|
Okay, the However I did some digging, and if I'm not mistaken, the RAML 1.0 specification allows for this syntax: #%RAML 1.0
title: test
mediaType: application/json
types:
Client:
properties:
id: string
resourceTypes:
collection:
get:
responses:
200:
body:
<<resourceType>>[]
/clients:
type: { collection: { resourceType: Client } } After stepping through Osprey's code, I found that in the
If I'm not mistaken, it should be fine to simply skip expanding Resource Types altogether to prevent this error from happening, since the application of Resource Types seems to be something Edit Actually, looking further, I found that
#%RAML 1.0
title: test
mediaType: application/json
types:
test:
properties:
test_value: string
resourceTypes:
testType:
post:
body:
type: <<resourcePathName>>
/test:
type: testType to { types:
[ { test:
{ name: 'test',
displayName: 'test',
typePropertyKind: 'TYPE_EXPRESSION',
type: [ 'object' ],
properties:
{ test_value:
{ name: 'test_value',
displayName: 'test_value',
typePropertyKind: 'TYPE_EXPRESSION',
type: [ 'string' ],
required: true } } } } ],
resourceTypes:
[ { testType:
{ name: 'testType',
post:
{ body:
{ body:
{ name: 'body',
displayName: 'body',
typePropertyKind: 'TYPE_EXPRESSION',
type: [ '<<resourcePathName>>' ] } },
method: 'post' } } } ],
title: 'test',
mediaType: 'application/json',
resources:
[ { methods:
[ { body:
{ 'application/json':
{ name: 'application/json',
displayName: 'application/json',
typePropertyKind: 'TYPE_EXPRESSION',
type: [ 'test' ] } },
method: 'post' } ],
type: 'testType',
relativeUri: '/test',
displayName: '/test',
relativeUriPathSegments: [ 'test' ],
absoluteUri: '/test' } ] } and after applying { additionalProperties: true,
type: 'object',
displayName: 'application/json',
name: 'application/json',
typePropertyKind: 'TYPE_EXPRESSION',
properties:
{ test_value:
{ type: 'string',
displayName: 'test_value',
name: 'test_value',
typePropertyKind: 'TYPE_EXPRESSION',
required: true } } } } I'll create a PR for my changes. |
You are totally right! Thanks for this. I'll review/comment your PR. |
Looking even further into the issue, I don't see anymore why you're expanding types at all - The type expansion however does have some bugs, but that looks like it's an issue with Edit: Edit2: |
I'm currently testing the raml1.0 branch and encountered this error while testing resource types:
Looks to me like
<<resourcePathName>>
is not properly replaced withtest
before it is passed on to the datatype-expansion module.I managed to produce this error with this example:
index.js
test.raml
The text was updated successfully, but these errors were encountered: