Skip to content
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

Default values for parameters are not populated #451

Closed
wparad opened this issue Mar 25, 2021 · 1 comment
Closed

Default values for parameters are not populated #451

wparad opened this issue Mar 25, 2021 · 1 comment

Comments

@wparad
Copy link

wparad commented Mar 25, 2021

When there is a default value in the openapi spec, it isn't being auto populated in the resource paths:
image

It would be great to have that default value be the one populated into the input box.

Technically this is doable by having the spec updated on load using lodash

import { cloneDeepWith } from 'lodash';

onSpecLoaded(data) {
      function updateTag(tag) {
        const picker = (value, key) => {
          if (!value || typeof value !== 'object') {
            return value;
          }

          if (Object.prototype.hasOwnProperty.call(value, 'default') && !value.example) {
            return Object.assign(value, { example: value.default });
          }

          return undefined;
        };
        return cloneDeepWith(tag, picker);
      }

      data.detail.tags = data.detail.tags.map(tag => updateTag(tag));
    }
@mrin9
Copy link
Collaborator

mrin9 commented Mar 25, 2021

The behavior is intended and not a bug.
Default is the value that the API-Server will fill in, when it is empty, not what a client will provide.

If you need to fill the inputs with some data use example or examples check out #397 for some context

@mrin9 mrin9 closed this as completed Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants