OpenAPITools / OpenAPITools/openapi-generator

[Bash] Enforcement of required parameters is not working when there is 1 required parameter and 0 provided parameters

Open
#12,584 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/OpenAPITools/openapi-generator/blob/7d092e76a1a7912519e67315eda87b819ea937c0/modules/openapi-generator/src/main/resources/bash/client.mustache#L408

This doesn't work for empty input parameters list, when exactly one parameter is required, e.g. client.sh someOperation. This is because above line's stdin "${operation_parameters[$qparam]}" produces one empty line, so we get associative array with default key 0 and value "". I.e. ${#operation_parameters} is equal to 1.

My suggested solution would be to change above line to:

mapfile -t parameter_values < <( { sed -e 's/'":::"'/\n/g' | sed -E '/\s*/d'; } <<<"${operation_parameters[$qparam]}")

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 at modules/openapi-generator/src/main/resources/bash/client.mustache around line 408 and reproduce the issue with client.sh someOperation when the operation has one required parameter and no supplied parameters. Verify that empty input does not create a parameter entry and that enforcement still rejects the missing required parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.