jdiegodcp / ramlfications

Python parser for RAML
https://ramlfications.readthedocs.org
Apache License 2.0
234 stars 50 forks source link

named object access in object collections #100

Open buhman opened 8 years ago

buhman commented 8 years ago

In raml that looks like this:

post:
  body:
    application/json:
      ...

When traversing that resource in the raw raml, a response type could be accessed like this:

mime_type = node['body']['application/json']

In the representation in ramlfications, equivalent access would look like this:

mime_type = [m for m in node.body if m.mime_type == 'application/json'][0]

This also applies to pretty much anything, including RootNode.resources.

What do you think about changing the pattern to something like:

{
  'application/json': Body()
}