OAI / OAI/OpenAPI-Specification

Path Templating with multiple parameters allows for ambiguous parsing

Open
#1,970 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

clarification request matching
Dominant language
Markdown
Stars
31.2k
Forks
9.2k
Avg merge
6h 37m
Merged PRs (30d)
27

Description

Currently the support for path segments is ambiguous even in simple cases:

Consider:

paths:
  /{foo}:{bar}/update:
    post:
      summary: Example API with multiple parameters
      parameters:
        - name: foo
          in: path
          description: Foo
          required: true
          schema:
            type: string
        - name: bar
          in: path
          description: Bar
          required: true
          schema:
            type: string

If the URL /a:b:c/update is received, there are two possible parses which, as far as I can tell, the spec doesn't state which is correct.

  • foo = a, bar = b:c
  • foo = a:b, bar = c

This means that two different implementations may have different interpretations of how parameters map through.

Note, from an implementation perspective, this gets more challenging, as in order to parse the URL to work out which operation it is, you need to know the full structure of the path parameter, as that may break the ambiguity (e.g. if bar is an enum which can only take values c, or d, then the parse collapses into the second option).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the path-template example in this issue and review the OpenAPI specification's rules for path parameters and operation matching. The work is done when the specification defines an unambiguous interpretation for URLs such as /a🅱️c/update, including how parameter constraints affect matching.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.