Skip to content

Make parent parameter object optional if all fields are optional #940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dolencd opened this issue Sep 9, 2022 · 2 comments
Closed

Make parent parameter object optional if all fields are optional #940

dolencd opened this issue Sep 9, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project planned Expected in an upcoming version PRs welcome PRs are welcome to solve this issue!

Comments

@dolencd
Copy link

dolencd commented Sep 9, 2022

When a specification defines some parameters, such as:

{
  "name": "id",
  "in": "path",
  "required": true,
  "type": "string"
},
{
  "name": "accept-language",
  "in": "header",
  "required": false,
  "type": "string"
}

The current output contains:

parameters: {
    path: {
      id: string;
    };
    header: {
      "accept-language"?: string;
    };
};

Maybe this would be a good option rather than the default behaviour, but I'd like the header key in this example to be optional. This makes sense since all the fields included in it are optional and you may want to include none of them.

@drwpow drwpow added enhancement New feature or request PRs welcome PRs are welcome to solve this issue! good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project planned Expected in an upcoming version labels Oct 30, 2022
@drwpow
Copy link
Contributor

drwpow commented Oct 30, 2022

This makes sense, and I’d argue this is expected behavior, because it means most requests likely happen without specifying those headers at all.

I don’t think this scenario would apply to all situations where this happens, but here in headers I think it’s a good improvement.

Would love a PR fixing this if someone has time.

@drwpow
Copy link
Contributor

drwpow commented Nov 4, 2022

Update: this has been added in #968 and will ship with the next v6 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project planned Expected in an upcoming version PRs welcome PRs are welcome to solve this issue!
Projects
None yet
Development

No branches or pull requests

2 participants