-
Notifications
You must be signed in to change notification settings - Fork 10
Include Schemas in raml context #6
Comments
It should be accessible on each resource |
Ok.. the initial reason behind this is to have the ability to generate language bindings for the schemas, such as java pojos from the schemas, that are then used by the SDK templates. Of course it doesn't matter the order until the code is actually compiled or used, but right now I am running a separate task outside of raml-generator to find and run jsonschema2pojo on all the .json files in a specified directory. It would be far better to have a list of all schemas in one shot. Also, in the case of using each resource schema: attribute, it allows for aliases to the schemas: list at the root of the RAML doc, so I would still need a way to match a resource schema alias to the root schema it refers to if the resource schema is not inlined or included at that point. |
@blakeembrey, first the |
So I'll add to this after talking with Blake a bit on gitter yesterday. On Wed, Apr 8, 2015 at 11:53 PM, Christian Vogel [email protected]
|
Yes, that's correct. It's a feature of the current RAML 0.8 parser. A lot of schema stuff (I think) relies on context like the media type of the body. There's also request/response schemas. It should be an all or none feature, so if we make a global schema feature we should rewrite all the schemas to be references to the global instance. What do you think? var allSchemas = {
[id: string]: {
id: string /* Same name as parent, can be completely random/unique like resource/method ids */
schema: string
}
}
var resource = {
body: {
'application/json': {
schema: /* Reference to the global schema instance */
}
}
} |
I do like the idea of global schema but can I urge for the sake of memory
|
If the schemas loading become an issue to you, please let me know. Right now loading the schema strings is a decision by the current RAML 0.8 parser, but we can look at patching it with additional features when needed. |
Fair enough.
|
Currently, the schemas defined in the root of a raml file, as well as schemas embedded within the raml file are not accessible in any way via the raml context object.
It would be ideal to have a allSchemas (like allResources) option that would be a flat list of all schema files. This should be some form of object though.. because in some cases the schemas are include files, and in others they are inlined. I'd argue against loading up all the include schemas into memory and work towards not using inlined schemas at all, but it is what it is now, so I'd urge that we keep the flat list that includes the type (inline or file) and the actual value (the path/file, or the string of inlined schema).
Then perhaps for each resource, we have the schema option so that as we iterate a resource, we can access the schema if need be (maybe this is there now? I haven't looked to see if that is possible).
The text was updated successfully, but these errors were encountered: