fix: clean and correct the missed files

This commit is contained in:
Arian Rahimi 2020-01-16 10:15:26 +03:30
parent e00ec86bcf
commit 4b4f30f344
10 changed files with 98 additions and 54 deletions

View File

@ -81,7 +81,6 @@
"@types/tapable": "1.0.4",
"@types/webpack": "^4.32.1",
"@types/webpack-env": "^1.14.0",
"@types/whatwg-fetch": "^0.0.33",
"@types/yargs": "^13.0.0",
"babel-loader": "8.0.6",
"babel-plugin-styled-components": "^1.10.6",

View File

@ -1,5 +1,4 @@
import * as React from 'react';
import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
import styled from '../styled-components';
export const Button = styled.button`
background: #248fb2;
@ -10,11 +9,11 @@ export const Button = styled.button`
padding: 5px;
`;
export const SendButton = Button.extend`
export const SendButton = styled(Button)`
background: #B0045E;
`;
export const ConsoleButton = Button.extend`
export const ConsoleButton = styled(Button)`
background: #e2e2e2;
color: black;
float: right;

View File

@ -1,5 +1,4 @@
import * as React from 'react';
import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
import styled from '../styled-components';
export const TextField = styled.input`
padding: 0.5em;

View File

@ -80,10 +80,10 @@ export const FlexLayout = styled.div`
width: 100%;
`;
export const ConsoleActionsRow = FlexLayout.extend`
export const ConsoleActionsRow = styled(FlexLayout)`
padding: 5px 0px;
`;
export const FlexLayoutReverse = FlexLayout.extend`
export const FlexLayoutReverse = styled(FlexLayout)`
flex-direction: row-reverse;
`;

View File

@ -1,5 +1,4 @@
import * as React from 'react';
import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components';
import styled from '../styled-components';
export const Toggle = styled.input`
padding: 0.5em;

View File

@ -9,12 +9,6 @@ import 'brace/theme/github';
import 'brace/theme/monokai';
import { MediaTypeModel } from '../../services/models';
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
import { MediaTypeSamples } from '../PayloadSamples/MediaTypeSamples';
import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
import { InvertedSimpleDropdown, MimeLabel } from '../PayloadSamples/styled.elements';
export interface ConsoleEditorProps {
mediaTypes: MediaTypeModel[];
@ -35,7 +29,8 @@ export class ConsoleEditor extends React.Component<ConsoleEditorProps> {
for (const mediaType of mediaTypes) {
if (mediaType.name.indexOf('json') > -1) {
if (mediaType.examples) {
sample = mediaType.examples && mediaType.examples.default && mediaType.examples.default.value;
const example = getDefaultOrFirst(mediaType.examples);
sample = example && example.value;
}
break;
}
@ -44,10 +39,16 @@ export class ConsoleEditor extends React.Component<ConsoleEditorProps> {
return (
<div>
<AceEditor
tabSize={1}
setOptions={{
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
enableSnippets: true,
showLineNumbers: true,
tabSize: 2,
}}
fontSize={10}
mode="json"
theme="github"
theme="monokai"
name="request-builder-editor"
editorProps={{ $blockScrolling: true }}
value={JSON.stringify(sample, null, 2)}
@ -60,3 +61,15 @@ export class ConsoleEditor extends React.Component<ConsoleEditorProps> {
}
}
function getDefaultOrFirst(object) {
if (typeof object === 'object') {
if (typeof object.default === 'object') {
return object.default;
} else {
return object[Object.keys(object)[0]];
}
} else {
return false;
}
}

View File

@ -4,7 +4,6 @@ import { SendButton } from '../../common-elements/buttons';
import { ConsoleActionsRow } from '../../common-elements/panels';
import { FieldModel, OperationModel } from '../../services/models';
import { OpenAPISchema } from '../../types';
import { PayloadSamples } from '../PayloadSamples/PayloadSamples';
import { SourceCodeWithCopy } from '../SourceCode/SourceCode';
import { ConsoleEditor } from './ConsoleEditor';
@ -41,25 +40,15 @@ export class ConsoleViewer extends React.Component<ConsoleViewerProps, ConsoleVi
}
onClickSend = async () => {
const ace = this.consoleEditor && this.consoleEditor.editor;
// const value = ace && ace.editor &&
const schema = this.getSchema();
const { operation, additionalHeaders = {} } = this.props;
// console.log('Schema: ' + JSON.stringify(schema, null, 2));
let value = ace && ace.editor.getValue();
const ref = schema && schema._$ref;
// var valid = window && window.ajv.validate({ $ref: `specs.json${ref}` }, value);
// console.log(JSON.stringify(window.ajv.errors));
// if (!valid) {
// console.warn('INVALID REQUEST!');
// }
const content = operation.requestBody && operation.requestBody.content;
const mediaType = content && content.mediaTypes[content.activeMimeIdx];
const endpoint = {
method: operation.httpVerb,
path: operation.servers[0].url + operation.path,
};
// console.log('Value: ' + value);
if (value) {
value = JSON.parse(value);
}
@ -127,7 +116,6 @@ export class ConsoleViewer extends React.Component<ConsoleViewerProps, ConsoleVi
const contentType = result.headers.get('content-type');
if (contentType && contentType.indexOf('application/json') !== -1) {
// successful cross-domain connect/ability
const resp = await result.json();
return { json: resp, statusCode: result.status, _fetchRes: result };
@ -203,11 +191,9 @@ export class ConsoleViewer extends React.Component<ConsoleViewerProps, ConsoleVi
for (const mediaType of mediaTypes) {
if (mediaType.name.indexOf('json') > -1) {
if (mediaType.schema) {
// schema = mediaType.schema;
schema.rawSchema = mediaType.schema && mediaType.schema.rawSchema;
console.log('rawSchema : ' + JSON.stringify(schema));
console.log('schema : ' + JSON.stringify(mediaType.schema.schema));
schema._$ref = mediaType.schema && mediaType.schema._$ref;
}
break;
}

View File

@ -3,7 +3,7 @@ import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement
import { observer } from 'mobx-react';
import { Badge, ConsoleButton, DarkRightPanel, FlexLayoutReverse, H2, MiddlePanel, Row, Toggle } from '../../common-elements';
import { Badge, ConsoleButton, DarkRightPanel, FlexLayoutReverse, H2, MiddlePanel, Row } from '../../common-elements';
import { OptionsContext } from '../OptionsProvider';
@ -21,26 +21,17 @@ import { OperationModel as OperationType } from '../../services/models';
import styled from '../../styled-components';
import { Extensions } from '../Fields/Extensions';
const OperationRow = Row.extend`
const OperationRow = styled(Row)`
backface-visibility: hidden;
contain: content;
overflow: hidden;
position: relative;
&:after {
position: absolute;
bottom: 0;
width: 100%;
display: block;
content: '';
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
`;
const Description = styled.div`
margin-bottom: ${({ theme }) => theme.spacing.unit * 6}px;
`;
export interface OperationProps {
operation: OperationType;
}

View File

@ -10,5 +10,3 @@ import 'core-js/es/symbol';
import 'unfetch/polyfill/index';
import 'url-polyfill';
import 'whatwg-fetch';

View File

@ -570,6 +570,14 @@
"@babel/helper-regex" "^7.4.4"
regexpu-core "^4.5.4"
"@babel/polyfill@^7.4.4":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/polyfill/-/polyfill-7.8.3.tgz#2333fc2144a542a7c07da39502ceeeb3abe4debd"
integrity sha512-0QEgn2zkCzqGIkSWWAEmvxD7e00Nm9asTtQvi7HdlYvMhjy/J38V/1Y9ode0zEJeIuxAI0uftiAzqc7nVeWUGg==
dependencies:
core-js "^2.6.5"
regenerator-runtime "^0.13.2"
"@babel/preset-env@^7.0.0":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.5.5.tgz#bc470b53acaa48df4b8db24a570d6da1fef53c9a"
@ -915,10 +923,10 @@
dependencies:
"@babel/types" "^7.3.0"
"@types/chai@4.1.7":
version "4.1.7"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.7.tgz#1b8e33b61a8c09cbe1f85133071baa0dbf9fa71a"
integrity sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==
"@types/chai@4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.3.tgz#b8a74352977a23b604c01aa784f5b793443fb7dc"
integrity sha512-f5dXGzOJycyzSMdaXVhiBhauL4dYydXwVpavfQ1mVCaGjR56a9QfklXObUxlIY9bGTmCPHEEZ04I16BZ/8w5ww==
"@types/cheerio@*":
version "0.22.12"
@ -1052,11 +1060,21 @@
resolved "https://registry.yarnpkg.com/@types/prismjs/-/prismjs-1.16.0.tgz#4328c9f65698e59f4feade8f4e5d928c748fd643"
integrity sha512-mEyuziLrfDCQ4juQP1k706BUU/c8OGn/ZFl69AXXY6dStHClKX4P+N8+rhqpul1vRDA2VOygzMRSJJZHyDEOfw==
"@types/promise@^7.1.30":
version "7.1.30"
resolved "https://registry.yarnpkg.com/@types/promise/-/promise-7.1.30.tgz#1b6714b321fdfc54d1527e7a17116a0e1f2ab810"
integrity sha1-G2cUsyH9/FTRUn56FxFqDh8quBA=
"@types/prop-types@*", "@types/prop-types@^15.7.1":
version "15.7.1"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
integrity sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==
"@types/qs@^6.5.1":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.0.tgz#2a5fa918786d07d3725726f7f650527e1cfeaffd"
integrity sha512-c4zji5CjWv1tJxIZkz1oUtGcdOlsH3aza28Nqmm+uNDWBRHoMsjooBEN4czZp1V3iXPihE/VRUOBqg+4Xq0W4g==
"@types/react-dom@^16.8.5":
version "16.8.5"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.8.5.tgz#3e3f4d99199391a7fb40aa3a155c8dd99b899cbd"
@ -1114,11 +1132,16 @@
"@types/react-native" "*"
csstype "^2.2.0"
"@types/tapable@*", "@types/tapable@1.0.4":
"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"
integrity sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ==
"@types/tapable@1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.2.tgz#e13182e1b69871a422d7863e11a4a6f5b814a4bd"
integrity sha512-42zEJkBpNfMEAvWR5WlwtTH22oDzcMjFsL9gDGExwF8X8WvAiw7Vwop7hPw03QT8TKfec83LwbHj6SvpqM4ELQ==
"@types/uglify-js@*":
version "3.0.4"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.4.tgz#96beae23df6f561862a830b4288a49e86baac082"
@ -1449,7 +1472,7 @@ ajv@^5.5.2:
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"
ajv@^6.1.0, ajv@^6.10.2, ajv@^6.5.5, ajv@^6.9.1:
ajv@^6.1.0, ajv@^6.10.2, ajv@^6.4.0, ajv@^6.5.5, ajv@^6.9.1:
version "6.10.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52"
integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==
@ -1953,6 +1976,11 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"
brace@^0.11.1:
version "0.11.1"
resolved "https://registry.yarnpkg.com/brace/-/brace-0.11.1.tgz#4896fcc9d544eef45f4bb7660db320d3b379fe58"
integrity sha1-SJb8ydVE7vRfS7dmDbMg07N5/lg=
braces@^2.3.1, braces@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729"
@ -2879,6 +2907,11 @@ core-js@^2.5.7:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==
core-js@^2.6.5:
version "2.6.11"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c"
integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==
core-js@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.1.4.tgz#3a2837fc48e582e1ae25907afcd6cf03b0cc7a07"
@ -3323,6 +3356,11 @@ dezalgo@^1.0.0:
asap "^2.0.0"
wrappy "1"
diff-match-patch@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.4.tgz#6ac4b55237463761c4daf0dc603eb869124744b1"
integrity sha512-Uv3SW8bmH9nAtHKaKSanOQmj2DnlH65fUpcrMdfdaOxUG02QQ4YGZ8AE7kKOMisF7UqvOlGKVYWRvezdncW9lg==
diff-sequences@^24.3.0:
version "24.3.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.3.0.tgz#0f20e8a1df1abddaf4d9c226680952e64118b975"
@ -6205,6 +6243,11 @@ lodash.flattendeep@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=
lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
@ -7886,6 +7929,11 @@ qs@6.7.0:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
qs@^6.5.2:
version "6.9.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.1.tgz#20082c65cb78223635ab1a9eaca8875a29bf8ec9"
integrity sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA==
qs@~6.5.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
@ -7976,6 +8024,18 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-ace@^6.0.0:
version "6.6.0"
resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-6.6.0.tgz#a79457ef03c3b1f8d4fc598a003b1d6ad464f1a0"
integrity sha512-Jehhp8bxa8kqiXk07Jzy+uD5qZMBwo43O+raniGHjdX7Qk93xFkKaAz8LxtUVZPJGlRnV5ODMNj0qHwDSN+PBw==
dependencies:
"@babel/polyfill" "^7.4.4"
brace "^0.11.1"
diff-match-patch "^1.0.4"
lodash.get "^4.4.2"
lodash.isequal "^4.5.0"
prop-types "^15.7.2"
react-dom@^16.8.6:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.8.6.tgz#71d6303f631e8b0097f56165ef608f051ff6e10f"