raml-org / raml-js-parser-2

(deprecated)
Other
138 stars 53 forks source link

Reference cannot be resolved when resource type has optional methods #640

Closed nmarinel01 closed 7 years ago

nmarinel01 commented 7 years ago

Take this spec definition as example. It was specified at a Api-console issue. In this case, there is a resource type with 2 optional methods : get and post. There is also a library where a type is defined. At root raml, when resource type is referenced, if no method is defined, the following error is returned: [ { code: 'UNRESOLVED_REFERENCE', message: 'Reference: \'test.Customer\' can not be resolved', path: 'api.raml', line: undefined, column: undefined, position: undefined, range: { start: [Object], end: [Object] }, trace: [ [Object] ] } ]

I would spec an error message regarding the lack of get/post method definition instead of this githup_393.zip

ddenisenko commented 7 years ago

@nmarinel01 thank you, it is reproducible.

@KonstantinSviridov this one is reproducible with library expansion on. Also please check the original ticket https://github.com/mulesoft/api-console/issues/393 - it's interesting that adding get does actually remove the error.

KonstantinSviridov commented 7 years ago

What has been happening here is that on library expansion we have been throwing away test.Customer type as unused. On the other hand, the validator has been seeing the typeName parameter appearing as TypeDeclaration.type value in resource type definition, and has been requireing it to be a reference on existing type.

Now the library expansion understands template parameters which appear as TypeDeclaration.type values and, thus, consideres the referenced types used and does not throw them away.

KonstantinSviridov commented 7 years ago

The fix is available in the develop branches set and is going to be brought to master with the next release (1.1.15)