Skip to content

Validate correct use of traits #295

Description

@stmeissner

It looks like the RAML validator has issues when traits are used at the wrong place in the API spec.
When defining this trait for a HTTP method header:

traits:
  right-header:
    headers:
      Accept:
        displayName: Accept Header
        type: string
        description: Accept Header
        required: true
        pattern: ^application/json$
        default: application/json

and using it at a wrong place in the API spec (the header must be on the method):

/{identifier}:
  uriParameters:
    identifier:
      displayName: DataSource Identifier
      type: string
      description: The data source identifier.
  is:
    - right-header
  get:
  ...

Actual behavior

The RAML validator does not complain.

When I model the same explicitly without the trait:

/{identifier}:
  uriParameters:
    identifier:
      displayName: DataSource Identifier
      type: string
      description: The data source identifier.
  headers:
    Accept:
      displayName: Accept Header
      type: string
      description: Accept Header
      required: true
      pattern: ^application/json$
      default: application/json
  get:
  ...

the RAML validator throws an error as expected.

Expected behavior

The RAML validator throws an error when using the trait at a place where its content is not compliant to the RAML standard.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions