path-parameters-defined

Since 0.0.1 · fixed by --fix · In the rulesets: Recommended at error, Strict at error, All at error

This rule checks that every {placeholder} of a path has a parameter with in: path and that name, on the path item or on each of its operations.

Rule details

A placeholder without a parameter has no type, no description and no required: true: generated clients cannot fill it, and generated servers and mocks cannot validate it.

The rule reports One or more path parameters are missing on the path item or the operation.

Configuration

An object with one optional property, defaultType: the schema type --fix gives the parameters it adds, string by default. null turns the fix off.

Examples

Good. The placeholder has its parameter on the path item.

paths:
  /users/{userId}:
    parameters:
      - name: userId
        in: path
        required: true
        schema:
          type: string
    get:
      summary: Get a user by ID

Bad. userId is declared nowhere.

paths:
  /users/{userId}:
    get:
      summary: Get a user by ID

Automatic fixes

--fix adds the missing parameters to the path item, with in: path, required: true and a schema of the configured type.

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.

commands:
  lint:
    rules:
      path-parameters-defined: off
Was this helpful?