OpenAPITools / OpenAPITools/openapi-generator

[BUG] Validator does not parse parameters if they are separated with anything but slash

Open
#8,161 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I have an API that contains the endpoint which looks like this:

"/api/processor/v1/designs/{id}/preview/{width}x{height}"

It looks like that the openapi-generator-cli does not support URLs that include parameters separated with a character that differs from '/'. When I try to validate it using openapi-generator-cli, it returns the following:

$ openapi-generator-cli validate -i processor.min.json
Validating spec (processor.min.json)
Errors:
        - attribute paths.'/api/processor/v1/designs/{id}/preview/{width}x{height}'. Declared path
          parameter width}x{height needs to be defined as a path parameter in path or operation
          level

[error] Spec has 1 errors.

Not sure whether the OpenAPI specification does allow this, but NSwag swallows it as well as the online validator at apidevtools.org. So I think it is a parser bug.

openapi-generator version

Both 4.3.1 and the latest one from docker (5.0.0-SNAPSHOT)

OpenAPI declaration file content or url

I have prepared a min repro:

---
openapi: 3.0.1
info:
  title: AssetProcessor API
  version: v1
paths:
  "/api/processor/v1/designs/{id}/preview/{width}x{height}":
    get:
      operationId: DesignProcessor_PreparePreview
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          nullable: true
      - name: width
        in: path
        required: true
        schema:
          type: integer
          format: int32
      - name: height
        in: path
        required: true
        schema:
          type: integer
          format: int32
      responses:
        '200':
          description: Success
Steps to reproduce

Copy the above schema to a file named, say, schema.yml and run:

openapi-generator-cli validate -i schema.yml

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 schema.yml minimal reproduction and run openapi-generator-cli validate -i schema.yml. Trace validation of the path /api/processor/v1/designs/{id}/preview/{width}x{height} and confirm that width and height are recognized as separate path parameters; done means the command no longer reports them as an undefined combined parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.