Commit Graph

602 Commits

Author SHA1 Message Date
Tim Lai
a73783b73d feat: syntax highlighting of code section (#6236)
Co-authored-by: AdrieanKhisbe <adriean.khisbe@live.fr>
2020-07-17 15:29:15 -07:00
Tim Lai
2fd1e4037c feat(RequestBody): validation support for required fields (#6223)
fixes #5181

* application/json
* application/xml
* application/x-www-form-urlencoded

* Set requestBodyValue values to be an immutable Map, as "value". Previously stored as a normal String.
* This enables adding "errors" to the Map, for validation use

* note: getOAS3RequiredRequestBodyContentType requires state.spec,
* which is not available to state.oas3
2020-07-16 17:53:28 -07:00
Tim Lai
b68942c043 feat(RequestBody): set default true for 'send empty value' (#6228) 2020-07-16 17:01:18 -07:00
Tim Lai
a1589a679c style: replace var with let in /test files (#6164) 2020-06-23 10:16:23 -07:00
Tim Lai
faae3e9d2c style: fix indent spaces from 4 to 2 in test files (#6163) 2020-06-23 09:44:24 -07:00
Vladimir
41e595beda feat: Display nullable for object model itself (#5660) (#5868) 2020-06-22 18:01:33 -07:00
Tim Lai
b86e8e96dd fix: curlify agnostic to order of header values (#6152)
Refs #6082

* use curlify flag isMultipartFormDataRequest
* curlify test updated


Co-authored-by: Vladimir Gorej <vladimir.gorej@gmail.com>
2020-06-18 12:34:52 -07:00
David DE CARVALHO
ca1b19a31b feat: Display example value in Swagger ReadOnly documentation (#4422) 2020-06-15 15:23:28 -07:00
Aldrin Abastillas
973e1f7a9b feat: Copy response to clipboard #4300 (#5278)
* Move next to download button and match styling

Co-authored-by: Aldrin Abastillas <AAbastillas@rcanalytics.com>
Co-authored-by: Tim Lai <timothy.lai@gmail.com>
2020-06-15 15:08:10 -07:00
Vladimir Gorej
a616cb471d fix(Markdown): render markdown in more secure way
This commit changes markdown sanitization behaviour in following way:

class, style and data-* attributes are removed by default. These attributes
open possible vulnerability vectors to attackers.

The original behavior of sanitizer (before this commit) can be enabled by *useUnsafeMarkdown* configuration option.
Use this configuration option with caution and only in cases when you know
what you're doing.
2020-06-11 21:51:15 +02:00
Wesley Schwengle
117dcc9b16 Disable the validation badge for those who do not want it (#5994)
* disabled on string values: "127.0.0.1", "localhost", "none"
2020-06-10 15:31:35 -07:00
John
21f51494a2 fix: support variables in auth urls (#5913) 2020-06-10 14:45:02 -07:00
Matthew Morrissette
275c8f2ccf improvement: oauth "scopes" improvements (#6037)
* improvement: oauth "scopes" init parameter

* improvement: add "select all" and "select none" to oauth scopes popup
2020-06-10 11:27:54 -07:00
Tim Lai
5bbd3e71bd fix: bugs/4641 use wait on route alias (#6048) 2020-06-01 17:14:45 -07:00
Tim Lai
a371ba1ca9 fix: bugs/4641 flaky test (#6047)
* fix: flaky bugs/4641 test

* fix: apply isFunc check for security.getIn
2020-06-01 14:23:51 -07:00
mircohaug
eaca2f6fd8 Add empty data param to cURL if no POST request body was given (#6017)
* Add empty data param to cURL if no request body was given

Some middleware applications do not allow POST requests without a content-length header. By adding a empty data parameter to the curl command, the content-length header will be set by curl. Besides this it is more obvious to the user that no request body is sent.

* use double quotes like the rest of the curl command
2020-05-29 15:10:22 -07:00
Tim Lai
68185dd71a fix: remove special handling of non-FormData entries (#6036)
Ref: #6033

* 'createObjWithHashedKeys' validation consistency with isFunction
* 'createObjWithHashedKeys' additional jsdoc example
2020-05-28 09:16:21 -07:00
Tim Lai
add5753da4 test: improve reliability of /bugs/4641 (#6013)
Ref #6001
2020-05-27 15:45:23 -07:00
Tim Lai
3a65070bf5 fix: entries as property name (#6025) 2020-05-20 11:54:57 -07:00
Tim Lai
96c7b4cbf5 fix: curl array support within multipart/form-data (#3838) (#5999)
ft: utils.createObjWithHashedKeys
ft: curlify.extractKey
test: curlify with array representation
2020-05-13 16:59:37 -07:00
Tim Lai
4542806af6 bug: remove clearValidation from onTryoutClick (#5955) 2020-05-06 14:07:22 -07:00
Tim Lai
5eb23cdd48 ft: JsonSchema components are now ImmutableJS compliant (#5952)
bug: JsonSchema components should validate schema properties exists
  - schema
  - type
  - format
  - enum
bug: fix a debounce error in JsonSchema_string if value is null
ft: new simplified JsonSchemaArrayItemText component
test: use immutableJS for `json-schema-form` test
test: add dev scripts to run `cypress open`
test: new cypress `schema-form` tests
2020-05-06 13:57:58 -07:00
Adam Jones
e98e7be4ec improvement: render OAS3 parameter type formats (#5796)
* Feature: Render OAS3 parameter type formats

* Add more test cases to parameter-row

* Update test/mocha/components/parameter-row.jsx

Co-Authored-By: Helen Kosova <hkosova@users.noreply.github.com>

* Update src/core/components/parameter-row.jsx

Co-authored-by: Helen Kosova <hkosova@users.noreply.github.com>
Co-authored-by: kyle shockey <kyleshockey@gmail.com>
2020-03-08 20:22:17 -04:00
Simon Legg
c9d6ac4cfc improvement: clear auth information from memory when logging out (#5316)
* clears authentications when logout is clicked

* tests the headers sent in the network request

* adds test for multiple api keys

* refactors tests to extract common uses

* correct test message description

Co-authored-by: kyle shockey <kyleshockey@gmail.com>
2020-01-14 21:20:39 -05:00
Jamie Peabody
e8266a3c6d fix: code highlight styles are now only applied pre.microlight (#5673)
* patch(#5672): code highlight styles are now only applied to pre blocks that have the class pre.microlight

* fixed pre style appied to .request-url

* fixed response-headers and request-duration pre blocks

* made pre.microlight class as per review

* added microlight class to appropriate pre and added tests
2019-11-03 20:46:38 -05:00
kyle
75a0e5d5dc fix(validateParam): validate JSON parameter values + support Parameter.content (#5657)
* improve(getParameterSchema): ParameterSchemaDescriptor pattern

* chore: update usage of `getParameterSchema`

* consider `Parameter.content` media type when validating JSON values
2019-10-11 11:20:23 -07:00
poveilleux
139592e353 feat: add PKCE support for OAuth2 Authorization Code flows (#5361)
* Add PKCE support.

* Fix tests

* Update oauth2.md

* Rename usePkce

* Fix the BrokenComponent error

* Update oauth2.md

* Remove isCode variable. Remove uuid4 dependency.

* Remove utils functions

* Import crypto

* Fix tests

* Fix the tests

* Cleanup

* Fix code_challenge generation

* Move code challenge and verifier to utils for mocks. Update tests.

* Mock the PKCE methods in the utils file properly.

* Add missing expect

* use target-method spies

* Add comments to explain test values.

* Get rid of jsrsasign.
2019-10-07 17:24:43 -07:00
kyle
5f6ec8ce1d fix: mitigate "sequential @import chaining" vulnerability (#5616)
* `test/e2e-cypress/tests/features/xss/` -> `test/e2e-cypress/tests/security`

* add tests

* filter <style> tags out of Markdown fields

* initialize OAuth inputs without applying `value` attribute
2019-09-20 13:19:08 -07:00
kyle
00c8e964e7 fix: accept string-represented values in required array runtime validation (#5609)
* rename `listCheck` -> `arrayListCheck`

* allow non-empty strings to quality a required array value
2019-09-15 12:17:42 -07:00
kyle
85f2bf3688 fix: <Select disabled> for type: string + enum schemas (#5601)
* fix: pass `disabled` through JsonSchemaForm – JsonSchema_string – Select

* migrate 5452 regression test
2019-09-10 22:08:03 -07:00
kyle
f523ec40f0 housekeeping: reorganize and rewire Mocha tests (#5600)
* move Mocha-run tests to `test/mocha`

* fix relative paths

* fix JSX test paths

* update stagnated JSX tests

* `test/setup.js` -> `test/mocha/setup.js`

* use regex+globstar for test matching

* remove `console.log`
2019-09-10 21:26:21 -07:00
kyle
94c86d3d50 improvement: online.swagger.io -> validator.swagger.io (#5599) 2019-09-09 21:33:23 -07:00
kyle
c9c3b2338e feature: support for Parameter.content (#5571)
* add `getParameterSchema` OAS helper

* use `Parameter.content.[firstKey].schema` as schema value when present

* `newValue` -> `initialValue`

* make `paramWithMeta` a const

* add trailing comma to `swagger2SchemaKeys`

* refactor `helpers` to a folder

* deprecate `src/core/utils.js` in favor of `src/core/helpers/`

* support `Parameter.content.[mediaType].schema` in validateParam

* reject `null` as an OAS3 object value

* expose Fetch errors in the browser console

* generate ParameterRow default values based on `content` values

* add tests for `getParameterSchema`

* remove debugger statement

* remove debugger statement

* don't apply `generatedSampleValue`s to parameters with `examples`

* remove extra semi

* disable JSON check in parameter runtime validation

* stringify JsonSchema_object textarea values

* add Cypress tests

* swagger-client@3.9.4
2019-08-31 16:37:43 -07:00
thierrydallacroce
0b3489b52d fix: remove .col class that causes collision with Bootstrap (via #5541)
* improvement: address Bootstrap conflict by removing our .col class (#4574)

* use `.parameters-col_description` selector in Cypress tests
2019-08-20 19:51:45 -07:00
kyle
877ee38ba1 housekeeping: non-breaking dependency updates (via #5515)
* non-breaking dependency updates

* eslint updates
2019-08-01 19:06:03 -07:00
kyle
39f8ceba55 fix: empty ModelExample rendering in a Response w/o content (via #5504)
* add failing test

* use falsy notSetValue for oas3SchemaForContentType
2019-07-29 22:15:19 -05:00
kyle
e895fb544f fix: use null as a notSetValue for examplesForMediaType (via #5503)
* fix: use null as a notSetValue for examplesForMediaType

fixes #5455

* tests!
2019-07-29 21:44:14 -05:00
kyle
be5e057bfa housekeeping: npm audit resolutions (via #5457)
* add `security-audit` script

* npm audit fix

* remove nyc

* nightwatch@1

this breaks the test suite, but it appears to have already regressed. leaving it for another day, TODO: open a backlog ticket

* add `security-audit` script

* disable mocha exclusivity

* update package-lock.json

* cypress@3.4.0

* `npm audit fix`

* @release-it/conventional-changelog@1.1.0

* release-it@12
2019-07-18 22:02:24 -05:00
kyle
a9493a27be fix: Swagger 2.0 Response.examples, again (via #5465)
* fix: Swagger 2.0 `Response.examples`

* stringify results
2019-07-13 01:01:57 -05:00
kyle
9749a47853 fix: Swagger 2.0 Response.examples (via #5464) 2019-07-13 00:25:43 -05:00
kyle
eaa1f4a8b4 bug: enum Select crashes when selecting the empty value (via #5463)
* add failing tests

* fix property access

* @babel/plugin-proposal-optional-chaining
2019-07-12 23:05:00 -05:00
kyle
9f10ab1d65 housekeeping: cypress standalone failures (via #5446)
* webpack.dist-style.config.js -> webpack-dist-style.config.js

* correctly generate stylesheets in dev server

* attempt to recover from missing StandalonePlugin in Cypress runner
2019-07-08 01:15:26 -05:00
kyle
21bb452cb7 housekeeping: address inconsistently truncated JS asset responses within Cypress tests (via #5445)
* add Cypress error trace

* Update package.json

* Update webpack-hot-dev-server.config.js

* Update index.js

* Update index.js
2019-07-08 00:19:40 -05:00
kyle
23d7260f92 feat: Multiple Examples for OpenAPI 3 Parameters, Request Bodies, and Responses (via #5427)
* add opt-in Prettier config

* remove legacy `examples` implementation

* create ExamplesSelect

* support `Response.examples` in OpenAPI 3

* create response controls group

* prettier reformat

* prepare to break up Parameters

* reunify Parameters and OAS3 Parameters

* Parameter Examples

* Example component

* handle parameter value stringification correctly

* FOR REVIEW: add prop for controlling Select

* use regular header for param examples in Try-It-Out

* manage active examples member via Redux

* Request Body Try-It-Out examples

* remove special Response description styling

* omit Example value display in Try-It-Out

* support disabled text inputs in JsonSchemaForm

* Example.omitValue => Example.showValue

* ExamplesSelectValueRetainer

* styling for disabled inputs

* remove console.log

* support "Modified Values" in ExamplesSelect

* remove Examples component
(wasn't used anywhere)

* use ParameterRow.getParamKey for active examples member keying

* split-rendering of examples in ParameterRow

* send disabled prop to JsonSchemaForm

* use content type to key request body active examples members

* remove debugger

* rewire RequestBodyEditor to be a controlled component

REVIEW: does this have perf implications?

* trigger synthetic onSelect events in ExamplesSelect

* prettier updates

* remove outdated Examples usage in RequestBody

* don't handle examples changes in ESVR

* make RequestBodyEditor semi-controlled

* don't default to an empty Map for request bodies

* add namespaceKey to ESVR for state mgmt

* don't key RequestBody activeExampleKeys on media type

* tweak ESVR isModifiedValueSelected calculation

* add trace class to ExamplesSelect

* remove usage of ESVR.currentNamespace

* reset to first example if currentExampleKey is invalid

* add default values to RequestBody rendering

* stringify things in ESVR

* avoid null select value (silences React warning)

* detect user inputs that match any examples member's value

* add trace class for json-schema-array

* shallowly convert namespace state, to preserve Immutable stucts in state

* stringify RBE values; don't trim JSON in editor

* match user input to an example when non-primitives are expressed in state as strings

* update Cypress

* don't apply sample values in JsonSchema_Object

* support disabling all JsonSchemaForm subcomponents

* Core tests

* style changes to accomodate Examples

* fix version-checking error in Response

* disable SCU for Responses

* don't stringify Select values

* ModelExample: default to Model tab if no example is available; provide a default no example message

* don't trim JSON ParamBody inputs

* read directly from 2.0 Response.schema instead of inferring a value

* show current Example information in RequestBody

* show label for Examples dropdown by default

* rework Response content ordering

* style disabled textareas like other read-only blocks

* meta: fix sourcemaps

* refactor ESVR setNameForNamespace

* protect second half of ternary expession

* cypress: `select.examples-select` => `.examples-select > select`

* clarify ModelExample.componentWillReceiveProps

* add gates/defaults to prevent issues in very bare-boned documents

* fix test block organization problem

* simplify RequestBodyEditor interface

* linter fixes

* prettier updates

* use plugin system for new components

* move ME Cypress helpers to other file
2019-06-29 19:52:51 +01:00
Segev Finer
be72c292ca feature: add withCredentials configuration key (via #5149)
* Add the withCredentials configuration key

It enables passing credentials in CORS requests. e.g. Cookies and
Authorization headers.

* Improve withCredentials documentation

* Add unit tests for the withCredentials config

* Update configuration.md

* Update configuration.md

* only set `withCredentials` Fetch flag if the config value is truthy

there are some workarounds in the wild today that involve setting `withCredentials` on `system.fn.fetch` directly. 

this approach avoids mangling those existing workarounds!

* add more test cases

* Update configs-wrap-actions.js

* Update index.js
2019-03-20 12:36:08 -07:00
kyle
ff496fa5bd fix: type safety for operation summary handling (via #5191)
* fix: gracefully handle non-string operation summaries

* use lodash for more summary type safety
2019-02-23 17:00:29 -08:00
kyle
1e184e8e21 fix: sanitize URLs used for OAuth auth flow (via #5190)
* fix: sanitize URLs used for OAuth auth flow

* embetter test case

* fix linter issue
2019-02-23 14:14:30 -08:00
kyle
d9f460f4a8 fix: gracefully handle non-string operation summaries (via #5189) 2019-02-19 15:41:16 -08:00
kyle
291e2c7251 improvement: operation path + summary overflow styling (via #5184)
* improvement: operation path + summary overflow styling

* inject zero-width spaces for better path breaking

* migrate 4867 regression test to tolerate new ZWSPs

* rm `dev-helpers/doc.yaml`
2019-02-15 20:05:26 -06:00
kyle
373da3bee3 fix: provide JSON editor for x-www-form-urlencoded bodies lacking properties (via #5180) 2019-02-13 18:47:01 -06:00