Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate correct use of traits #295

Open
stmeissner opened this issue Dec 7, 2022 · 0 comments
Open

Validate correct use of traits #295

stmeissner opened this issue Dec 7, 2022 · 0 comments

Comments

@stmeissner
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant