问题
I use this extension for Atom, to design my API, written in RAML.
I think I have a problem here :(I masked title and baseUri, sorry) :
If I follow RAML 1.0 specs, I should put a "!include". Strangely, apiworkbench detects no mistake.
If I do that :
Why didn't this work?
回答1:
No, for libraries you must NOT use the include keyword.
It seems the specification is not very clear about this or at least I could not find it clearly specified anywhere. Thus raising an issue about this would be a good idea.
But if you check the examples in the specification you will see that when using libraries (with the "uses" keyword) the "!include" is omitted.
回答2:
Very good conversations. Indeed the specification should be more clear about that, but the reason why libraries follows a different approach than normal !include
is that an include simply adds new nodes to an existing where ever you used the !include
keyword. Since it really is a simple "add" operation, it does not cover up for any cyclic dependencies.
Libraries are very much different and the use of namespaces (uses
) are very much different. The purpose of libraries is to create a common shareable group of assets/definitions of best practices that people also use to create their own libraries or other definitions on top. Cyclic dependencies are inevitable. For that, the RAML workgroup had to come up with a different mechanism than what you have with !include
. Hence, for libraries you should always use:
uses
lib: mylib.raml
Hope that explains the rationality behind it, but please let me know if you have more questions.
来源:https://stackoverflow.com/questions/42397718/raml-include-strange-behavior