From 1a1bc26503c06b6a7022289e5b9353bd59e48a9a Mon Sep 17 00:00:00 2001 From: Alex Varchuk Date: Mon, 18 Jul 2022 17:48:26 +0300 Subject: [PATCH] fix: restore old variant security injections (#2075) --- demo/openapi.yaml | 2 +- src/services/AppStore.ts | 12 +++++++++++- .../__snapshots__/loadAndBundleSpec.test.ts.snap | 2 +- src/utils/openapi.ts | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/demo/openapi.yaml b/demo/openapi.yaml index 4008f2e2..dabf41d4 100644 --- a/demo/openapi.yaml +++ b/demo/openapi.yaml @@ -38,7 +38,7 @@ info: OAuth2 - an open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications. - + version: 1.0.0 title: Swagger Petstore diff --git a/src/services/AppStore.ts b/src/services/AppStore.ts index 415b6949..082557f3 100644 --- a/src/services/AppStore.ts +++ b/src/services/AppStore.ts @@ -13,7 +13,11 @@ import { SearchStore } from './SearchStore'; import { SchemaDefinition } from '../components/SchemaDefinition/SchemaDefinition'; import { SecurityDefs } from '../components/SecuritySchemes/SecuritySchemes'; -import { SCHEMA_DEFINITION_JSX_NAME, SECURITY_DEFINITIONS_JSX_NAME } from '../utils/openapi'; +import { + SCHEMA_DEFINITION_JSX_NAME, + SECURITY_DEFINITIONS_JSX_NAME, + OLD_SECURITY_DEFINITIONS_JSX_NAME, +} from '../utils/openapi'; import { IS_BROWSER } from '../utils'; import type { StoreState } from './types'; @@ -150,6 +154,12 @@ const DEFAULT_OPTIONS: RedocRawOptions = { securitySchemes: store.spec.securitySchemes, }), }, + [OLD_SECURITY_DEFINITIONS_JSX_NAME]: { + component: SecurityDefs, + propsSelector: (store: AppStore) => ({ + securitySchemes: store.spec.securitySchemes, + }), + }, [SCHEMA_DEFINITION_JSX_NAME]: { component: SchemaDefinition, propsSelector: (store: AppStore) => ({ diff --git a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap index 5f526a74..b676fc7e 100644 --- a/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap +++ b/src/utils/__tests__/__snapshots__/loadAndBundleSpec.test.ts.snap @@ -513,7 +513,7 @@ Petstore offers two forms of authentication: OAuth2 - an open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications. - + ", "license": Object { "name": "Apache 2.0", diff --git a/src/utils/openapi.ts b/src/utils/openapi.ts index d3a55154..564fe7de 100644 --- a/src/utils/openapi.ts +++ b/src/utils/openapi.ts @@ -631,6 +631,7 @@ export function normalizeServers( } export const SECURITY_DEFINITIONS_JSX_NAME = 'SecurityDefinitions'; +export const OLD_SECURITY_DEFINITIONS_JSX_NAME = 'security-definitions'; export const SCHEMA_DEFINITION_JSX_NAME = 'SchemaDefinition'; export let SECURITY_SCHEMES_SECTION_PREFIX = 'section/Authentication/';