swagger-api / swagger-api/swagger-parser

[Bug] Style simple + Object with Path Variables is not working

Open
#2,090 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

Hi, I am using swagger request validator library (version 2.22.0) in my project with below yaml configurations.

info:
  title: Sample API
  version: 1.0.0
openapi: 3.0.0
paths:
  /demo/{groupIdentifier}:
    get:
      description: This API which will provide all the members of a group.
      operationId: get-group-v2
      responses:
        "200":
          description: Successful response
    parameters:
    - description: Composite group identifier
      explode: false
      in: path
      name: groupIdentifier
      required: true
      allowReserved: true
      schema:
        properties:
          domainCode:
            description: Code of the master data domain
            type: string
          groupTypeCode:
            description: The prototype type of the group that has to be searched
            type: string
        type: object
      style: simple

running api gives me below error :
{ "fault": { "faultstring": "OASValidation MAM-SpecValidation with resource "oas://openapi.yaml": failed with reason: "[ERROR - Unable to parse JSON - Unrecognized token 'domainCode': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n\t at [Source: (String)"domainCode,CUSTOMER,groupTypeCode,CUSTOMER_GROUP"; line: 1, column: 11].: []]"", "detail": { "errorcode": "steps.oasvalidation.Failed" } } }

in the api call, I am passing path variables in object format (comma seperated) as mentioned in the doc - https://swagger.io/docs/specification/serialization/

ex. http://test.com/demo/domainCode,CUSTOMER,groupTypeCode,CUSTOMER_GROUP

Also, I debugged the library and found that its trying to convert comma-seperated values in json and hence, giving this error.

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

Reproduce the issue using the openapi.yaml configuration and the OASValidation request shown, starting with swagger-parser's handling of simple-style object path parameters. Check how the comma-separated value is converted before JSON parsing. Done means the documented domainCode,CUSTOMER,groupTypeCode,CUSTOMER_GROUP value is accepted without the JSON parsing error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.