Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Fix issue where default values wouldn't be saved into the formData un…
Browse files Browse the repository at this point in the history
…til edited

You can test this locally here: http://localhost:9966/?selected=swagger-files%2Ftypes.json
Search for "default value" and see that it is already in the code sample.

This issue luckily got fixed upstream:
rjsf-team/react-jsonschema-form#1034

So to bring that in I needed to update my fork of the module.

I would love to get off of my fork and get back onto the main release,
but there's some outstanding work on my PR which means we can't right now:
rjsf-team/react-jsonschema-form#954
  • Loading branch information
domharrington committed Dec 12, 2018
1 parent 70a2ac0 commit 7487581
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 12 additions & 1 deletion packages/api-explorer/__tests__/Params.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ test('{ type: string, format: binary } should render as <input type="file">', ()
expect(params.find('.field-file').length).toBe(1);
});

function renderParams(schema) {
function renderParams(schema, customProps) {
return mount(
<div>
<Params
{...props}
{...customProps}
operation={
new Operation(oas, '/path', 'post', {
requestBody: {
Expand Down Expand Up @@ -232,3 +233,13 @@ describe('readOnly', () => {
).toBe(1);
});
});

test('defaults should be applied on first render', (done) => {
const defaultValue = 'this is a default value';
function onChange(formData) {
expect(formData.body).toEqual({ a: defaultValue });
return done();
}

renderParams({ type: 'string', default: defaultValue }, { onChange });
});
12 changes: 6 additions & 6 deletions packages/api-explorer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7487581

Please sign in to comment.