Skip to content

Path Templating: is there a restriction on the path parameter name? #1969

@jmini

Description

@jmini

According to the specification, each defined path parameter must correspond to a same-named variable placeholder in the path:

name: If in is "path", the name field MUST correspond to the associated path segment from the path field in the Paths Object. See Path Templating for further information.

There is no information about what is a valid name. Is there any restriction/recommendation about the characters that should or must be used?

For example, for:

GET <server>/api/231

231 corresponds to the path parameter.

In the following example with the name is todoID:

openapi: 3.0.1
info:
    title: Todo Backend
    version: '1.0'
paths:
    '/api/{todoID}':
        get:
            parameters:
                -  name: todoID
                   description: The id of the todo
                   schema:
                        format: int64
                        type: integer
                   in: path
                   required: true
            responses:
                '200':
                    description: OK
            summary: Get one todo

An other example with todo-id:

openapi: 3.0.1
info:
    title: Todo Backend
    version: '1.0'
paths:
    '/api/{todo-id}':
        get:
            parameters:
                -  name: todo-id
                   description: The id of the todo
                   schema:
                        format: int64
                        type: integer
                   in: path
                   required: true
            responses:
                '200':
                    description: OK
            summary: Get one todo

Are both names (todoID and todo-id) allowed?

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