mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-25 10:03:45 +03:00
fix: skipReadOnly/skipWritOnly not passing down to nested OneOf
This commit is contained in:
parent
02c2413da8
commit
2462639f76
|
@ -47,7 +47,7 @@ export class OneOfSchema extends React.Component<SchemaProps> {
|
|||
<OneOfButton key={subSchema._$ref} schema={schema} subSchema={subSchema} idx={idx} />
|
||||
))}
|
||||
</OneOfList>
|
||||
<Schema schema={oneOf[schema.activeOneOf]} />
|
||||
<Schema {...this.props} schema={oneOf[schema.activeOneOf]} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
|
|||
}
|
||||
|
||||
if (oneOf !== undefined) {
|
||||
return <OneOfSchema schema={schema} />;
|
||||
return <OneOfSchema schema={schema} {...this.props} />;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
|
44
src/components/Schema/__tests__/OneOfSchema.test.tsx
Normal file
44
src/components/Schema/__tests__/OneOfSchema.test.tsx
Normal file
|
@ -0,0 +1,44 @@
|
|||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import toJson from 'enzyme-to-json';
|
||||
|
||||
import { filterPropsDeep } from '../../../utils/test-utils';
|
||||
|
||||
import { RedocNormalizedOptions } from '../../../services/RedocNormalizedOptions';
|
||||
import { OpenAPIParser, SchemaModel } from '../../../services';
|
||||
import { Schema } from '../Schema';
|
||||
import { OneOfSchema } from '../OneOfSchema';
|
||||
|
||||
const options = new RedocNormalizedOptions({});
|
||||
describe('Components', () => {
|
||||
describe('SchemaView', () => {
|
||||
describe('OneOf', () => {
|
||||
it('should pass down skipReadOnly/skipReadWrite to nested oneOf', () => {
|
||||
const parser = new OpenAPIParser(
|
||||
{ openapi: '3.0', info: { title: 'test', version: '0' }, paths: {} },
|
||||
undefined,
|
||||
options,
|
||||
);
|
||||
|
||||
const schema = new SchemaModel(
|
||||
parser,
|
||||
{ oneOf: [{ type: 'string' }, { type: 'integer' }] },
|
||||
'',
|
||||
options,
|
||||
);
|
||||
let schemaViewElement = shallow(
|
||||
<Schema schema={schema} skipWriteOnly={true} />,
|
||||
).getElement();
|
||||
expect(schemaViewElement.type).toEqual(OneOfSchema);
|
||||
expect(schemaViewElement.props.skipWriteOnly).toBeTruthy();
|
||||
expect(schemaViewElement.props.skipReadOnly).toBeFalsy();
|
||||
|
||||
schemaViewElement = shallow(<Schema schema={schema} skipReadOnly={true} />).getElement();
|
||||
|
||||
expect(schemaViewElement.type).toEqual(OneOfSchema);
|
||||
expect(schemaViewElement.props.skipWriteOnly).toBeFalsy();
|
||||
expect(schemaViewElement.props.skipReadOnly).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user