Skip to content

Commit

Permalink
chore: convert jsv
Browse files Browse the repository at this point in the history
  • Loading branch information
casserni authored and P0lip committed May 17, 2019
1 parent 96eb511 commit 00f2a61
Show file tree
Hide file tree
Showing 25 changed files with 140 additions and 657 deletions.
33 changes: 0 additions & 33 deletions src/__fixtures__/ref/original.json

This file was deleted.

31 changes: 31 additions & 0 deletions src/__fixtures__/ref/original.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { JSONSchema4 } from 'json-schema';

export const schemaWithRefs: JSONSchema4 = {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {
address: {
type: 'object',
properties: {
street_address: {
type: 'string',
},
city: {
type: 'string',
},
state: {
type: 'string',
},
},
required: ['street_address', 'city', 'state'],
},
},
type: 'object',
properties: {
billing_address: {
$ref: '#/definitions/address',
},
shipping_address: {
$ref: '#/definitions/address',
},
},
};
65 changes: 0 additions & 65 deletions src/__fixtures__/ref/resolved.json

This file was deleted.

55 changes: 55 additions & 0 deletions src/__fixtures__/ref/resolved.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { JSONSchema4 } from 'json-schema';

export const dereferencedSchema: JSONSchema4 = {
$schema: 'http://json-schema.org/draft-07/schema#',
definitions: {
address: {
type: 'object',
properties: {
street_address: {
type: 'string',
},
city: {
type: 'string',
},
state: {
type: 'string',
},
},
required: ['street_address', 'city', 'state'],
},
},
type: 'object',
properties: {
billing_address: {
type: 'object',
properties: {
street_address: {
type: 'string',
},
city: {
type: 'string',
},
state: {
type: 'string',
},
},
required: ['street_address', 'city', 'state'],
},
shipping_address: {
type: 'object',
properties: {
street_address: {
type: 'string',
},
city: {
type: 'string',
},
state: {
type: 'string',
},
},
required: ['street_address', 'city', 'state'],
},
},
};
39 changes: 0 additions & 39 deletions src/__mocks__/theme.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/__stories__/JsonSchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { State, Store } from '@sambego/storybook-state';
import { boolean, number, object, text, withKnobs } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { JsonSchemaViewer } from '../components/JsonSchemaViewer';
import { JsonSchemaViewer } from '../components';

import { JSONSchema4 } from 'json-schema';
import * as allOfSchemaResolved from '../__fixtures__/allOf/allOf-resolved.json';
Expand Down
32 changes: 0 additions & 32 deletions src/components/Additional.tsx

This file was deleted.

17 changes: 5 additions & 12 deletions src/components/Divider.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { Box, Flex, IFlex } from '@stoplight/ui-kit';
import * as React from 'react';
import { IJsonSchemaViewerTheme, useTheme } from '../theme';
import { MutedText } from './common/MutedText';

export const Divider: React.FunctionComponent<IFlex> = ({ children, ...props }) => {
const theme = useTheme() as IJsonSchemaViewerTheme;

export const Divider: React.FunctionComponent<React.HTMLAttributes<HTMLDivElement>> = ({ children, ...props }) => {
return (
<Flex alignItems="center" position="absolute" top="-16px" left="0" height="10px" {...props}>
<MutedText fontSize=".8rem" textTransform="uppercase" fontWeight={700} pr={7}>
{children}
</MutedText>
<Box backgroundColor={theme.divider.bg} height="2px" flex="1 1 0%" />
</Flex>
<div className="flex items-center w-full h-2 absolute" style={{ top: -16, left: -16 }} {...props}>
<div className="uppercase font-bold text-darken-7 pr-2">{children}</div>
<div className="flex-1 bg-darken-5" style={{ height: 2 }} />
</div>
);
};
13 changes: 0 additions & 13 deletions src/components/Enum.tsx

This file was deleted.

22 changes: 4 additions & 18 deletions src/components/JsonSchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { TreeStore } from '@stoplight/tree-list';
import { Omit } from '@stoplight/types';
import { runInAction } from 'mobx';
import * as React from 'react';
import { ThemeZone } from '../theme';

import { isSchemaViewerEmpty, renderSchema } from '../utils';
import { ErrorMessage } from './common/ErrorMessage';
import { MutedText } from './common/MutedText';
import { ISchemaTree, SchemaTree } from './SchemaTree';

export interface IJsonSchemaViewer extends Omit<ISchemaTree, 'emptyText' | 'treeStore'> {
Expand Down Expand Up @@ -73,26 +71,14 @@ export class JsonSchemaViewer extends React.PureComponent<IJsonSchemaViewer, IJs
} = this;

if (error) {
return (
<ThemeZone name="json-schema-viewer">
<ErrorMessage>{error}</ErrorMessage>
</ThemeZone>
);
return <div>{error}</div>;
}

// an empty array or object is still a valid response, schema is ONLY really empty when a combiner type has no information
if (isSchemaViewerEmpty(schema)) {
return (
<ThemeZone name="json-schema-viewer">
<MutedText>{emptyText}</MutedText>
</ThemeZone>
);
return <div>{emptyText}</div>;
}

return (
<ThemeZone name="json-schema-viewer">
<SchemaTree expanded={expanded} name={name} schema={schema} treeStore={this.treeStore} {...props} />
</ThemeZone>
);
return <SchemaTree expanded={expanded} name={name} schema={schema} treeStore={this.treeStore} {...props} />;
}
}
6 changes: 3 additions & 3 deletions src/components/MaskedSchema.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Dialog } from '@stoplight/ui-kit';
import * as React from 'react';
import { IJsonSchemaViewer, JsonSchemaViewer } from './JsonSchemaViewer';
import { IJsonSchemaViewer, JsonSchemaViewer } from './';

export interface IMaskedSchema extends IJsonSchemaViewer {
onClose(): void;
}

export const MaskedSchema: React.FunctionComponent<IMaskedSchema> = ({ onClose, ...props }) => {
return (
<Dialog show onClickOutside={onClose} width="50vh" height="50vh" position="relative">
<JsonSchemaViewer {...props} canSelect />
<Dialog isOpen={true} onClose={onClose}>
<JsonSchemaViewer {...props} style={{ height: 500 }} canSelect />
</Dialog>
);
};
Loading

0 comments on commit 00f2a61

Please sign in to comment.