@backstage/plugin-catalog-backend-module-openapi 0.1.26-next.2 → 0.1.27-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/README.md +27 -0
- package/dist/index.cjs.js +25 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend-module-openapi
|
|
2
2
|
|
|
3
|
+
## 0.1.27-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/backend-common@0.21.0-next.0
|
|
9
|
+
- @backstage/plugin-catalog-backend@1.17.0-next.0
|
|
10
|
+
- @backstage/plugin-catalog-node@1.6.2-next.0
|
|
11
|
+
- @backstage/backend-plugin-api@0.6.10-next.0
|
|
12
|
+
- @backstage/catalog-model@1.4.3
|
|
13
|
+
- @backstage/config@1.1.1
|
|
14
|
+
- @backstage/integration@1.8.0
|
|
15
|
+
- @backstage/types@1.1.1
|
|
16
|
+
- @backstage/plugin-catalog-common@1.0.20
|
|
17
|
+
|
|
18
|
+
## 0.1.26
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 4ebf99b: Add support for the new backend system.
|
|
23
|
+
|
|
24
|
+
A new backend module for the catalog backend
|
|
25
|
+
was added and exported as `default`.
|
|
26
|
+
|
|
27
|
+
You can use it with the new backend system like
|
|
28
|
+
|
|
29
|
+
```ts title="packages/backend/src/index.ts"
|
|
30
|
+
backend.add(import('@backstage/plugin-catalog-backend-module-openapi'));
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @backstage/backend-common@0.20.1
|
|
35
|
+
- @backstage/backend-plugin-api@0.6.9
|
|
36
|
+
- @backstage/plugin-catalog-node@1.6.1
|
|
37
|
+
- @backstage/plugin-catalog-backend@1.16.1
|
|
38
|
+
- @backstage/catalog-model@1.4.3
|
|
39
|
+
- @backstage/config@1.1.1
|
|
40
|
+
- @backstage/integration@1.8.0
|
|
41
|
+
- @backstage/types@1.1.1
|
|
42
|
+
- @backstage/plugin-catalog-common@1.0.20
|
|
43
|
+
|
|
3
44
|
## 0.1.26-next.2
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,6 +17,33 @@ yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-openapi
|
|
|
17
17
|
|
|
18
18
|
### Adding the plugin to your `packages/backend`
|
|
19
19
|
|
|
20
|
+
```ts title="packages/backend/src/index.ts"
|
|
21
|
+
backend.add(import('@backstage/plugin-catalog-backend-module-openapi'));
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This will add the `jsonSchemaRefPlaceholderResolver` for
|
|
25
|
+
the placeholder resolver keys `asyncapi` and `openapi`.
|
|
26
|
+
|
|
27
|
+
This allows you to use the `$openapi` placeholder when referencing your OpenAPI specification and `$asyncapi` when referencing your AsyncAPI specifications. This will then resolve all `$ref` instances in your specification.
|
|
28
|
+
|
|
29
|
+
You can also use this resolver for other kind of yaml files to resolve $ref pointer.
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
apiVersion: backstage.io/v1alpha1
|
|
33
|
+
kind: API
|
|
34
|
+
metadata:
|
|
35
|
+
name: example
|
|
36
|
+
description: Example API
|
|
37
|
+
spec:
|
|
38
|
+
type: openapi
|
|
39
|
+
lifecycle: production
|
|
40
|
+
owner: team
|
|
41
|
+
definition:
|
|
42
|
+
$openapi: ./spec/openapi.yaml # by using $openapi Backstage will now resolve all $ref instances
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Adding the plugin to your `packages/backend` (old backend system)
|
|
46
|
+
|
|
20
47
|
#### **jsonSchemaRefPlaceholderResolver**
|
|
21
48
|
|
|
22
49
|
The placeholder resolver can be added by importing `jsonSchemaRefPlaceholderResolver` in `src/plugins/catalog.ts` in your `backend` package and adding the following.
|
package/dist/index.cjs.js
CHANGED
|
@@ -7,6 +7,8 @@ var $RefParser = require('@apidevtools/json-schema-ref-parser');
|
|
|
7
7
|
var yaml = require('yaml');
|
|
8
8
|
var path = require('path');
|
|
9
9
|
var integration = require('@backstage/integration');
|
|
10
|
+
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
11
|
+
var alpha = require('@backstage/plugin-catalog-node/alpha');
|
|
10
12
|
|
|
11
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
14
|
|
|
@@ -179,9 +181,32 @@ class OpenApiRefProcessor {
|
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
|
|
184
|
+
const catalogModuleJsonSchemaRefPlaceholderResolver = backendPluginApi.createBackendModule({
|
|
185
|
+
pluginId: "catalog",
|
|
186
|
+
moduleId: "json-schema-ref-placeholder-resolver",
|
|
187
|
+
register(env) {
|
|
188
|
+
env.registerInit({
|
|
189
|
+
deps: {
|
|
190
|
+
catalog: alpha.catalogProcessingExtensionPoint
|
|
191
|
+
},
|
|
192
|
+
async init({ catalog }) {
|
|
193
|
+
catalog.addPlaceholderResolver(
|
|
194
|
+
"asyncapi",
|
|
195
|
+
jsonSchemaRefPlaceholderResolver
|
|
196
|
+
);
|
|
197
|
+
catalog.addPlaceholderResolver(
|
|
198
|
+
"openapi",
|
|
199
|
+
jsonSchemaRefPlaceholderResolver
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
182
206
|
const openApiPlaceholderResolver = jsonSchemaRefPlaceholderResolver;
|
|
183
207
|
|
|
184
208
|
exports.OpenApiRefProcessor = OpenApiRefProcessor;
|
|
209
|
+
exports["default"] = catalogModuleJsonSchemaRefPlaceholderResolver;
|
|
185
210
|
exports.jsonSchemaRefPlaceholderResolver = jsonSchemaRefPlaceholderResolver;
|
|
186
211
|
exports.openApiPlaceholderResolver = openApiPlaceholderResolver;
|
|
187
212
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lib/bundle.ts","../src/jsonSchemaRefPlaceholderResolver.ts","../src/OpenApiRefProcessor.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport $RefParser from '@apidevtools/json-schema-ref-parser';\nimport { parse, stringify } from 'yaml';\nimport * as path from 'path';\n\nconst protocolPattern = /^(\\w{2,}):\\/\\//i;\nconst getProtocol = (refPath: string) => {\n const match = protocolPattern.exec(refPath);\n if (match) {\n return match[1].toLowerCase();\n }\n return undefined;\n};\n\nexport type BundlerRead = (url: string) => Promise<Buffer>;\n\nexport type BundlerResolveUrl = (url: string, base: string) => string;\n\nexport async function bundleFileWithRefs(\n fileWithRefs: string,\n baseUrl: string,\n read: BundlerRead,\n resolveUrl: BundlerResolveUrl,\n): Promise<string> {\n const fileUrlReaderResolver: $RefParser.ResolverOptions = {\n canRead: file => {\n const protocol = getProtocol(file.url);\n return protocol === undefined || protocol === 'file';\n },\n read: async file => {\n const relativePath = path.relative('.', file.url);\n const url = resolveUrl(relativePath, baseUrl);\n return await read(url);\n },\n };\n const httpUrlReaderResolver: $RefParser.ResolverOptions = {\n canRead: ref => {\n const protocol = getProtocol(ref.url);\n return protocol === 'http' || protocol === 'https';\n },\n read: async ref => {\n const url = resolveUrl(ref.url, baseUrl);\n return await read(url);\n },\n };\n\n const options: $RefParser.Options = {\n resolve: {\n file: fileUrlReaderResolver,\n http: httpUrlReaderResolver,\n },\n };\n const fileObject = parse(fileWithRefs);\n const bundledObject = await $RefParser.bundle(baseUrl, fileObject, options);\n return stringify(bundledObject);\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PlaceholderResolverParams } from '@backstage/plugin-catalog-backend';\nimport { JsonValue } from '@backstage/types';\nimport { processingResult } from '@backstage/plugin-catalog-node';\nimport { bundleFileWithRefs } from './lib';\n\n/** @public */\nexport async function jsonSchemaRefPlaceholderResolver(\n params: PlaceholderResolverParams,\n): Promise<JsonValue> {\n const { content, url } = await readTextLocation(params);\n\n params.emit(processingResult.refresh(`url:${url}`));\n\n try {\n return await bundleFileWithRefs(\n content,\n url,\n params.read,\n params.resolveUrl,\n );\n } catch (error) {\n throw new Error(\n `Placeholder \\$${params.key} unable to bundle the file at ${params.value}, ${error}`,\n );\n }\n}\n\n/*\n * Helpers, copied from PlaceholderProcessor\n */\n\nasync function readTextLocation(\n params: PlaceholderResolverParams,\n): Promise<{ content: string; url: string }> {\n const newUrl = relativeUrl(params);\n\n try {\n const data = await params.read(newUrl);\n return { content: data.toString('utf-8'), url: newUrl };\n } catch (e) {\n throw new Error(\n `Placeholder \\$${params.key} could not read location ${params.value}, ${e}`,\n );\n }\n}\n\nfunction relativeUrl({\n key,\n value,\n baseUrl,\n resolveUrl,\n}: PlaceholderResolverParams): string {\n if (typeof value !== 'string') {\n throw new Error(\n `Placeholder \\$${key} expected a string value parameter, in the form of an absolute URL or a relative path`,\n );\n }\n\n try {\n return resolveUrl(value, baseUrl);\n } catch (e) {\n // The only remaining case that isn't support is a relative file path that should be\n // resolved using a relative file location. Accessing local file paths can lead to\n // path traversal attacks and access to any file on the host system. Implementing this\n // would require additional security measures.\n throw new Error(\n `Placeholder \\$${key} could not form a URL out of ${baseUrl} and ${value}, ${e}`,\n );\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { UrlReader } from '@backstage/backend-common';\nimport { Entity } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { CatalogProcessor } from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { bundleFileWithRefs } from './lib';\nimport { Logger } from 'winston';\n\n/**\n * @public\n * @deprecated replaced by the openApiPlaceholderResolver\n */\nexport class OpenApiRefProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrations;\n private readonly logger: Logger;\n private readonly reader: UrlReader;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; reader: UrlReader },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new OpenApiRefProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrations;\n logger: Logger;\n reader: UrlReader;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.reader = options.reader;\n }\n\n getProcessorName(): string {\n return 'OpenApiRefProcessor';\n }\n\n async preProcessEntity(\n entity: Entity,\n location: LocationSpec,\n ): Promise<Entity> {\n if (\n !entity ||\n entity.kind !== 'API' ||\n (entity.spec && entity.spec.type !== 'openapi')\n ) {\n return entity;\n }\n\n const scmIntegration = this.integrations.byUrl(location.target);\n const definition = entity.spec!.definition;\n\n if (!scmIntegration || !definition) {\n return entity;\n }\n\n const resolveUrl = (url: string, base: string): string => {\n return scmIntegration.resolveUrl({ url, base });\n };\n\n this.logger.debug(`Bundling OpenAPI specification from ${location.target}`);\n try {\n const read = async (url: string) => {\n const { buffer } = await this.reader.readUrl(url);\n return await buffer();\n };\n const bundledSpec = await bundleFileWithRefs(\n definition.toString(),\n location.target,\n read,\n resolveUrl,\n );\n\n return {\n ...entity,\n spec: { ...entity.spec, definition: bundledSpec },\n };\n } catch (error) {\n this.logger.error(`Unable to bundle OpenAPI specification`, error);\n return entity;\n }\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { jsonSchemaRefPlaceholderResolver } from './jsonSchemaRefPlaceholderResolver';\n\nexport { OpenApiRefProcessor } from './OpenApiRefProcessor';\nexport { jsonSchemaRefPlaceholderResolver } from './jsonSchemaRefPlaceholderResolver';\n/**\n * @public\n * @deprecated replaced by jsonSchemaRefPlaceholderResolver\n */\nexport const openApiPlaceholderResolver = jsonSchemaRefPlaceholderResolver;\n"],"names":["path","parse","$RefParser","stringify","processingResult","ScmIntegrations"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,eAAkB,GAAA,iBAAA,CAAA;AACxB,MAAM,WAAA,GAAc,CAAC,OAAoB,KAAA;AACvC,EAAM,MAAA,KAAA,GAAQ,eAAgB,C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AAAA,QACL,GAAG,MAAA;AAAA,QACH,MAAM,EAAE,GAAG,MAAO,CAAA,IAAA,EAAM,YAAY,WAAY,EAAA;AAAA,OAClD,CAAA;AAAA,aACO,KAAO,EAAA;AACd,MAAK,IAAA,CAAA,MAAA,CAAO,KAAM,CAAA,CAAA,sCAAA,CAAA,EAA0C,KAAK,CAAA,CAAA;AACjE,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAAA,GACF;AACF;;ACjFO,MAAM,0BAA6B,GAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lib/bundle.ts","../src/jsonSchemaRefPlaceholderResolver.ts","../src/OpenApiRefProcessor.ts","../src/module/catalogModuleJsonSchemaRefPlaceholderResolver.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport $RefParser from '@apidevtools/json-schema-ref-parser';\nimport { parse, stringify } from 'yaml';\nimport * as path from 'path';\n\nconst protocolPattern = /^(\\w{2,}):\\/\\//i;\nconst getProtocol = (refPath: string) => {\n const match = protocolPattern.exec(refPath);\n if (match) {\n return match[1].toLowerCase();\n }\n return undefined;\n};\n\nexport type BundlerRead = (url: string) => Promise<Buffer>;\n\nexport type BundlerResolveUrl = (url: string, base: string) => string;\n\nexport async function bundleFileWithRefs(\n fileWithRefs: string,\n baseUrl: string,\n read: BundlerRead,\n resolveUrl: BundlerResolveUrl,\n): Promise<string> {\n const fileUrlReaderResolver: $RefParser.ResolverOptions = {\n canRead: file => {\n const protocol = getProtocol(file.url);\n return protocol === undefined || protocol === 'file';\n },\n read: async file => {\n const relativePath = path.relative('.', file.url);\n const url = resolveUrl(relativePath, baseUrl);\n return await read(url);\n },\n };\n const httpUrlReaderResolver: $RefParser.ResolverOptions = {\n canRead: ref => {\n const protocol = getProtocol(ref.url);\n return protocol === 'http' || protocol === 'https';\n },\n read: async ref => {\n const url = resolveUrl(ref.url, baseUrl);\n return await read(url);\n },\n };\n\n const options: $RefParser.Options = {\n resolve: {\n file: fileUrlReaderResolver,\n http: httpUrlReaderResolver,\n },\n };\n const fileObject = parse(fileWithRefs);\n const bundledObject = await $RefParser.bundle(baseUrl, fileObject, options);\n return stringify(bundledObject);\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { PlaceholderResolverParams } from '@backstage/plugin-catalog-backend';\nimport { JsonValue } from '@backstage/types';\nimport { processingResult } from '@backstage/plugin-catalog-node';\nimport { bundleFileWithRefs } from './lib';\n\n/** @public */\nexport async function jsonSchemaRefPlaceholderResolver(\n params: PlaceholderResolverParams,\n): Promise<JsonValue> {\n const { content, url } = await readTextLocation(params);\n\n params.emit(processingResult.refresh(`url:${url}`));\n\n try {\n return await bundleFileWithRefs(\n content,\n url,\n params.read,\n params.resolveUrl,\n );\n } catch (error) {\n throw new Error(\n `Placeholder \\$${params.key} unable to bundle the file at ${params.value}, ${error}`,\n );\n }\n}\n\n/*\n * Helpers, copied from PlaceholderProcessor\n */\n\nasync function readTextLocation(\n params: PlaceholderResolverParams,\n): Promise<{ content: string; url: string }> {\n const newUrl = relativeUrl(params);\n\n try {\n const data = await params.read(newUrl);\n return { content: data.toString('utf-8'), url: newUrl };\n } catch (e) {\n throw new Error(\n `Placeholder \\$${params.key} could not read location ${params.value}, ${e}`,\n );\n }\n}\n\nfunction relativeUrl({\n key,\n value,\n baseUrl,\n resolveUrl,\n}: PlaceholderResolverParams): string {\n if (typeof value !== 'string') {\n throw new Error(\n `Placeholder \\$${key} expected a string value parameter, in the form of an absolute URL or a relative path`,\n );\n }\n\n try {\n return resolveUrl(value, baseUrl);\n } catch (e) {\n // The only remaining case that isn't support is a relative file path that should be\n // resolved using a relative file location. Accessing local file paths can lead to\n // path traversal attacks and access to any file on the host system. Implementing this\n // would require additional security measures.\n throw new Error(\n `Placeholder \\$${key} could not form a URL out of ${baseUrl} and ${value}, ${e}`,\n );\n }\n}\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { UrlReader } from '@backstage/backend-common';\nimport { Entity } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { ScmIntegrations } from '@backstage/integration';\nimport { CatalogProcessor } from '@backstage/plugin-catalog-node';\nimport { LocationSpec } from '@backstage/plugin-catalog-common';\nimport { bundleFileWithRefs } from './lib';\nimport { Logger } from 'winston';\n\n/**\n * @public\n * @deprecated replaced by the openApiPlaceholderResolver\n */\nexport class OpenApiRefProcessor implements CatalogProcessor {\n private readonly integrations: ScmIntegrations;\n private readonly logger: Logger;\n private readonly reader: UrlReader;\n\n static fromConfig(\n config: Config,\n options: { logger: Logger; reader: UrlReader },\n ) {\n const integrations = ScmIntegrations.fromConfig(config);\n\n return new OpenApiRefProcessor({\n ...options,\n integrations,\n });\n }\n\n constructor(options: {\n integrations: ScmIntegrations;\n logger: Logger;\n reader: UrlReader;\n }) {\n this.integrations = options.integrations;\n this.logger = options.logger;\n this.reader = options.reader;\n }\n\n getProcessorName(): string {\n return 'OpenApiRefProcessor';\n }\n\n async preProcessEntity(\n entity: Entity,\n location: LocationSpec,\n ): Promise<Entity> {\n if (\n !entity ||\n entity.kind !== 'API' ||\n (entity.spec && entity.spec.type !== 'openapi')\n ) {\n return entity;\n }\n\n const scmIntegration = this.integrations.byUrl(location.target);\n const definition = entity.spec!.definition;\n\n if (!scmIntegration || !definition) {\n return entity;\n }\n\n const resolveUrl = (url: string, base: string): string => {\n return scmIntegration.resolveUrl({ url, base });\n };\n\n this.logger.debug(`Bundling OpenAPI specification from ${location.target}`);\n try {\n const read = async (url: string) => {\n const { buffer } = await this.reader.readUrl(url);\n return await buffer();\n };\n const bundledSpec = await bundleFileWithRefs(\n definition.toString(),\n location.target,\n read,\n resolveUrl,\n );\n\n return {\n ...entity,\n spec: { ...entity.spec, definition: bundledSpec },\n };\n } catch (error) {\n this.logger.error(`Unable to bundle OpenAPI specification`, error);\n return entity;\n }\n }\n}\n","/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createBackendModule } from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { jsonSchemaRefPlaceholderResolver } from '../jsonSchemaRefPlaceholderResolver';\n\n/**\n * Registers the jsonSchemaRefPlaceholderResolver\n * as placeholder resolver for `$asyncapi` and `$openapi`.\n *\n * @public\n */\nexport const catalogModuleJsonSchemaRefPlaceholderResolver =\n createBackendModule({\n pluginId: 'catalog',\n moduleId: 'json-schema-ref-placeholder-resolver',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ catalog }) {\n catalog.addPlaceholderResolver(\n 'asyncapi',\n jsonSchemaRefPlaceholderResolver,\n );\n catalog.addPlaceholderResolver(\n 'openapi',\n jsonSchemaRefPlaceholderResolver,\n );\n },\n });\n },\n });\n","/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { jsonSchemaRefPlaceholderResolver } from './jsonSchemaRefPlaceholderResolver';\n\nexport { OpenApiRefProcessor } from './OpenApiRefProcessor';\nexport { jsonSchemaRefPlaceholderResolver } from './jsonSchemaRefPlaceholderResolver';\n/**\n * @public\n * @deprecated replaced by jsonSchemaRefPlaceholderResolver\n */\nexport const openApiPlaceholderResolver = jsonSchemaRefPlaceholderResolver;\n\nexport * from './module';\nexport { default } from './module';\n"],"names":["path","parse","$RefParser","stringify","processingResult","ScmIntegrations","createBackendModule","catalogProcessingExtensionPoint"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,eAAkB,GAAA,iBAAA,CAAA;AACxB,MAAM,WAAA,GAAc,CAAC,OAAoB,KAAA;AACvC,EAAM,MAAA,KAAA,GAAQ,eAAgB,CAAA,IAAA,CAAK,OAAO,CAAA,CAAA;AAC1C,EAAA,IAAI,KAAO,EAAA;AACT,IAAO,OAAA,KAAA,CAAM,CAAC,CAAA,CAAE,WAAY,EAAA,CAAA;AAAA,GAC9B;AACA,EAAO,OAAA,KAAA,CAAA,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M,CAAA,CAAA,sCAAA,CAAA,EAA0C,KAAK,CAAA,CAAA;AACjE,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAAA,GACF;AACF;;AC9EO,MAAM,gDACXC,oCAAoB,CAAA;AAAA,EAClB,QAAU,EAAA,SAAA;AAAA,EACV,QAAU,EAAA,sCAAA;AAAA,EACV,SAAS,GAAK,EAAA;AACZ,IAAA,GAAA,CAAI,YAAa,CAAA;AAAA,MACf,IAAM,EAAA;AAAA,QACJ,OAAS,EAAAC,qCAAA;AAAA,OACX;AAAA,MACA,MAAM,IAAA,CAAK,EAAE,OAAA,EAAW,EAAA;AACtB,QAAQ,OAAA,CAAA,sBAAA;AAAA,UACN,UAAA;AAAA,UACA,gCAAA;AAAA,SACF,CAAA;AACA,QAAQ,OAAA,CAAA,sBAAA;AAAA,UACN,SAAA;AAAA,UACA,gCAAA;AAAA,SACF,CAAA;AAAA,OACF;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAC;;ACxBI,MAAM,0BAA6B,GAAA;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { ScmIntegrations } from '@backstage/integration';
|
|
|
7
7
|
import { CatalogProcessor } from '@backstage/plugin-catalog-node';
|
|
8
8
|
import { LocationSpec } from '@backstage/plugin-catalog-common';
|
|
9
9
|
import { Logger } from 'winston';
|
|
10
|
+
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
10
11
|
|
|
11
12
|
/** @public */
|
|
12
13
|
declare function jsonSchemaRefPlaceholderResolver(params: PlaceholderResolverParams): Promise<JsonValue>;
|
|
@@ -32,10 +33,18 @@ declare class OpenApiRefProcessor implements CatalogProcessor {
|
|
|
32
33
|
preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Registers the jsonSchemaRefPlaceholderResolver
|
|
38
|
+
* as placeholder resolver for `$asyncapi` and `$openapi`.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
declare const catalogModuleJsonSchemaRefPlaceholderResolver: () => _backstage_backend_plugin_api.BackendFeature;
|
|
43
|
+
|
|
35
44
|
/**
|
|
36
45
|
* @public
|
|
37
46
|
* @deprecated replaced by jsonSchemaRefPlaceholderResolver
|
|
38
47
|
*/
|
|
39
48
|
declare const openApiPlaceholderResolver: typeof jsonSchemaRefPlaceholderResolver;
|
|
40
49
|
|
|
41
|
-
export { OpenApiRefProcessor, jsonSchemaRefPlaceholderResolver, openApiPlaceholderResolver };
|
|
50
|
+
export { OpenApiRefProcessor, catalogModuleJsonSchemaRefPlaceholderResolver as default, jsonSchemaRefPlaceholderResolver, openApiPlaceholderResolver };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-backend-module-openapi",
|
|
3
3
|
"description": "A Backstage catalog backend module that helps with OpenAPI specifications",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.27-next.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -33,20 +33,21 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@apidevtools/json-schema-ref-parser": "^9.0.6",
|
|
36
|
-
"@backstage/backend-common": "^0.
|
|
36
|
+
"@backstage/backend-common": "^0.21.0-next.0",
|
|
37
|
+
"@backstage/backend-plugin-api": "^0.6.10-next.0",
|
|
37
38
|
"@backstage/catalog-model": "^1.4.3",
|
|
38
39
|
"@backstage/config": "^1.1.1",
|
|
39
40
|
"@backstage/integration": "^1.8.0",
|
|
40
|
-
"@backstage/plugin-catalog-backend": "^1.
|
|
41
|
-
"@backstage/plugin-catalog-common": "^1.0.
|
|
42
|
-
"@backstage/plugin-catalog-node": "^1.6.
|
|
41
|
+
"@backstage/plugin-catalog-backend": "^1.17.0-next.0",
|
|
42
|
+
"@backstage/plugin-catalog-common": "^1.0.20",
|
|
43
|
+
"@backstage/plugin-catalog-node": "^1.6.2-next.0",
|
|
43
44
|
"@backstage/types": "^1.1.1",
|
|
44
45
|
"winston": "^3.2.1",
|
|
45
46
|
"yaml": "^2.1.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@backstage/backend-test-utils": "^0.
|
|
49
|
-
"@backstage/cli": "^0.25.
|
|
49
|
+
"@backstage/backend-test-utils": "^0.3.0-next.0",
|
|
50
|
+
"@backstage/cli": "^0.25.2-next.0",
|
|
50
51
|
"openapi-types": "^12.0.0"
|
|
51
52
|
},
|
|
52
53
|
"files": [
|