swagger-api / swagger-api/swagger-client

OpenApi v3 parameter default value not handled

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

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.7k
Forks
765
Avg merge
1d 1h
Merged PRs (30d)
6

Description

  • OS: mac
  • Environment: Chrome 105
  • Method of installation: npm
  • Swagger-Client version: 3.18.5
  • Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration

Swagger/OpenAPI definition:
PetstoreV3.yaml with default: 'whatever' property added to /user/login-get-parameters-username-schema

Swagger-Client usage:

SwaggerClient.execute({
    "spec": {...PetsoreV3JsonDescribedAbove}
    "method": "get",
    "pathName": "/user/login",
    "parameters": {},
    "requestContentType": "application/json",
    "responseContentType": "application/json",
})
Describe the bug you're encountering

On openApi v3, not supplied parameters with a default value are not sent when exucuting the corresponding action

To reproduce...

Steps to reproduce the behavior:

  1. In an openApi v3 spec action, add a default value to a non required parameter
  2. Execute the action without supplying the parameter which have a default value
Expected behavior

Not supplied parameter with a default value should be sent like in V2:
https://github.com/swagger-api/swagger-js/blob/master/src/execute/index.js#L215

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 src/execute/index.js, especially the referenced OpenAPI v2 default-parameter handling, and reproduce the behavior using PetstoreV3.yaml with SwaggerClient.execute. Done means an omitted non-required OpenAPI 3 parameter with a default value is included when executing the action.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
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.