diff --git a/src/common-elements/fields.ts b/src/common-elements/fields.ts index c8d0df1b..2fbac2cb 100644 --- a/src/common-elements/fields.ts +++ b/src/common-elements/fields.ts @@ -96,7 +96,6 @@ export const ConstraintItem = styled(FieldLabel)` margin: 0 ${theme.spacing.unit}px; padding: 0 ${theme.spacing.unit}px; border: 1px solid ${transparentize(0.9, theme.colors.primary.main)}; - font-family: ${theme.typography.code.fontFamily}; }`}; & + & { margin-left: 0; diff --git a/src/components/Fields/FieldDetail.tsx b/src/components/Fields/FieldDetail.tsx index a14cfb1d..53fb89bf 100644 --- a/src/components/Fields/FieldDetail.tsx +++ b/src/components/Fields/FieldDetail.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { ExampleValue, FieldLabel } from '../../common-elements/fields'; export interface FieldDetailProps { diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx index 80d35cee..c04a5b0f 100644 --- a/src/components/Fields/FieldDetails.tsx +++ b/src/components/Fields/FieldDetails.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useMemo } from 'react'; +import * as React from 'react'; import { RecursiveLabel, @@ -25,7 +25,7 @@ import { Pattern } from './Pattern'; import { ArrayItemDetails } from './ArrayItemDetails'; function FieldDetailsComponent(props: FieldProps) { - const { enumSkipQuotes, hideSchemaTitles } = useContext(OptionsContext); + const { enumSkipQuotes, hideSchemaTitles } = React.useContext(OptionsContext); const { showExamples, field, renderDiscriminatorSwitch } = props; const { schema, description, deprecated, extensions, in: _in, const: _const } = field; @@ -33,7 +33,7 @@ function FieldDetailsComponent(props: FieldProps) { const rawDefault = enumSkipQuotes || _in === 'header'; // having quotes around header field default values is confusing and inappropriate - const renderedExamples = useMemo(() => { + const renderedExamples = React.useMemo(() => { if (showExamples && (field.example !== undefined || field.examples !== undefined)) { if (field.examples !== undefined) { return ; diff --git a/src/components/Fields/Pattern.tsx b/src/components/Fields/Pattern.tsx index 56542b5b..3b0c17ea 100644 --- a/src/components/Fields/Pattern.tsx +++ b/src/components/Fields/Pattern.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useContext, useState } from 'react'; +import * as React from 'react'; import { PatternLabel, ToggleButton } from '../../common-elements/fields'; import { OptionsContext } from '../OptionsProvider'; import { SchemaModel } from '../../services'; @@ -7,9 +7,12 @@ const MAX_PATTERN_LENGTH = 45; export function Pattern(props: { schema: SchemaModel }) { const pattern = props.schema.pattern; - const { hideSchemaPattern } = useContext(OptionsContext); - const [isPatternShown, setIsPatternShown] = useState(false); - const togglePattern = useCallback(() => setIsPatternShown(!isPatternShown), [isPatternShown]); + const { hideSchemaPattern } = React.useContext(OptionsContext); + const [isPatternShown, setIsPatternShown] = React.useState(false); + const togglePattern = React.useCallback( + () => setIsPatternShown(!isPatternShown), + [isPatternShown], + ); if (!pattern || hideSchemaPattern) return null; diff --git a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap index 6cd0a034..5d30e78a 100644 --- a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap +++ b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap @@ -277,10 +277,102 @@ Object { }, }, "name": Object { - "description": "The name given to a pet", - "example": "Guru", + "description": "this is a description", + "items": Object { + "maxLength": 80, + "type": "string", + }, + "type": "array", + }, + "name1": Object { + "description": "this is a description", + "items": Object { + "pattern": "^[a-z]$", + "type": "string", + }, + "type": "array", + }, + "name10": Object { + "description": "description", + "maxLength": 80, + "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}$", "type": "string", }, + "name2": Object { + "description": "this is a description", + "items": Object { + "maxLength": 80, + "minLength": 2, + "type": "string", + }, + "type": "array", + }, + "name3": Object { + "description": "this is a description", + "items": Object { + "maxLength": 80, + "minLength": 2, + "pattern": "^[a-z]$", + "type": "string", + }, + "type": "array", + }, + "name4": Object { + "description": "this is a description", + "items": Object { + "multipleOf": 5, + "type": "integer", + }, + "maxItems": 5, + "type": "array", + }, + "name5": Object { + "description": "this is a description", + "items": Object { + "maximum": 10, + "multipleOf": 5, + "type": "integer", + }, + "type": "array", + }, + "name6": Object { + "description": "this is a description", + "items": Object { + "maximum": 10, + "minimum": 5, + "multipleOf": 5, + "type": "integer", + }, + "type": "array", + }, + "name7": Object { + "description": "this is a description", + "items": Object { + "maximum": 100, + "minimum": 1, + "type": "integer", + }, + "type": "array", + }, + "name8": Object { + "description": "this is a description", + "items": Object { + "exclusiveMaximum": true, + "maximum": 100, + "minimum": 1, + "type": "integer", + }, + "type": "array", + }, + "name9": Object { + "description": "this is a description", + "items": Object { + "exclusiveMaximum": 100, + "minimum": 1, + "type": "integer", + }, + "type": "array", + }, "petType": Object { "description": "Type of a pet", "type": "string", diff --git a/tsconfig.json b/tsconfig.json index 32bd4f3a..21dbb326 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,8 +15,7 @@ "pretty": true, "lib": ["es2015", "es2016", "es2017", "dom", "WebWorker.ImportScripts"], "jsx": "react", - "types": ["webpack", "webpack-env", "jest"], - "allowSyntheticDefaultImports": true + "types": ["webpack", "webpack-env", "jest"] }, "compileOnSave": false, "exclude": ["node_modules", ".tmp", "lib", "e2e/**"],