Errors when including traits

I have two traits which raml2html is happy with when they are in the main body of my raml, but when they are included as external files, raml2html reports errors.

When included as part of the main raml document, they look like this:

traits:

  resource_listing_head:
    responses:
      200:
        body:
          type: string

  uuid_validator:
    usage: Apply this to any resource which includes a uuid.
    description: |
      If the uuid-space in the URI does not contain a valid uuid,
      return 400 and a useful error message.
    responses:
      400:
        body:
          type: error
          example:
            description: Malformed URI
            debug: "AFISH is not a valid UUID"

And when brought in externally, they look like this:

api.raml:

traits:
  resource_listing_head: !include traits/resource_listing_head.raml
  uuid_validator: !include traits/uuid_validator.raml

traits/resource_listing_head.raml

#%RAML 1.0 Trait

responses:
  200:
    body:
      type: string

traits/uuid_validator.raml

#%RAML 1.0 Trait

usage: Apply this to any resource which includes a uuid.
description: |
  If the uuid-space in the URI does not contain a valid uuid,
  return 400 and a useful error message.
responses:
  400:
    body:
      type: error
      example:
        description: Malformed URI
        debug: "AFISH is not a valid UUID"

The error messages from the validator look like this:

UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  ERROR_IN_INCLUDED_FILE: Error in the included file: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:14:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within traits (traits/resource_listing_head.raml:5:3)
  ERROR_IN_INCLUDED_FILE: Error in the included file: RAML 1.0 does not allow using 'type' property within traits (WeaselMediaProcessingFrameworkServiceAPI.raml
:14:2)
UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  UNKNOWN_NODE: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:252:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (traits/resource_listing_head.raml:5:3)
  INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (WeaselMediaProcessingFrameworkServiceAPI.raml:252:2)
UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  UNKNOWN_NODE: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:269:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (traits/resource_listing_head.raml:5:3)
  INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (WeaselMediaProcessingFrameworkServiceAPI.raml:269:2)
UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  UNKNOWN_NODE: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:367:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (traits/resource_listing_head.raml:5:3)
  INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (WeaselMediaProcessingFrameworkServiceAPI.raml:367:2)
UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  UNKNOWN_NODE: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:456:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (traits/resource_listing_head.raml:5:3)
  INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (WeaselMediaProcessingFrameworkServiceAPI.raml:456:2)
UNKNOWN_NODE: Unknown node: '200' (traits/resource_listing_head.raml:3:1)
  UNKNOWN_NODE: Unknown node: '200' (WeaselMediaProcessingFrameworkServiceAPI.raml:558:2)
INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (traits/resource_listing_head.raml:5:3)
  INVALID_PROPERTY_USAGE: RAML 1.0 does not allow using 'type' property within methods (WeaselMediaProcessingFrameworkServiceAPI.raml:558:2)

I assume I’ve structured the include incorrectly, but I can’t see what’s wrong.

@Ruarl: I don’t see anything wrong with your RAML definitions. I would file a bug on the raml2html repo.

1 Like