raml-org / raml-spec

RAML Specification
http://raml.org
3.87k stars 857 forks source link

Splitting large type hierarchies across multiple files #598

Open KevinMitchell opened 7 years ago

KevinMitchell commented 7 years ago

Suppose I'm designing a complex API involving a large number of datatypes. To avoid creating one huge RAML file I decide to split the definition across multiple files. The first bit is easy, as I can just pull out all the type definitions into a separate library and make the main specification have a dependency on this library.

Now suppose in my type library I have a large datatype A which has no dependencies on any other type in the library, i.e. all the properties of A use primitive types. To avoid the types library itself becoming one huge RAML file I could take the definition of a type like A and move it into its own file as a typed fragment. For a large type that would seem quite natural.

But suppose I now want to pull out another large type, B, from the types library. But B has a dependency on A. At this point I get stuck. I can't move it to a typed fragment, as such fragments must be closed. If type A was in a different library to B I could add a uses declaration at the top of the fragment for B including the library containing A. But when they are in the same library this will presumably not work.

I could give up using typed fragments and simply !include chunks of specification, but then I lose some of the editor support when manipulating these files. So is there some better technique for handling this situation in RAML? And if not, does this suggest a limitation of the current language that needs further development?

sichvoge commented 7 years ago

Maybe my answer here helps, but your central point should always be a library.

Let me know if there is more.