@backstage/plugin-catalog-backend-module-openapi 0.1.5-next.0 → 0.1.5-next.2

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @backstage/plugin-catalog-backend-module-openapi
2
2
 
3
+ ## 0.1.5-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/plugin-catalog-backend@1.6.0-next.2
9
+ - @backstage/plugin-catalog-node@1.3.0-next.2
10
+ - @backstage/backend-common@0.17.0-next.2
11
+ - @backstage/catalog-model@1.1.4-next.1
12
+ - @backstage/config@1.0.5-next.1
13
+ - @backstage/integration@1.4.1-next.1
14
+ - @backstage/types@1.0.2-next.1
15
+
16
+ ## 0.1.5-next.1
17
+
18
+ ### Patch Changes
19
+
20
+ - dd995cdc72: Enabled support of resolving `$refs` in all kind of yaml documents, not only OpenAPI. This implicitly adds `$ref` resolving support for AsyncAPI specs. Thus, the `openApiPlaceholderResolver` has been renamed to `jsonSchemaRefPlaceholderResolver`.
21
+ - Updated dependencies
22
+ - @backstage/backend-common@0.17.0-next.1
23
+ - @backstage/plugin-catalog-backend@1.6.0-next.1
24
+ - @backstage/types@1.0.2-next.1
25
+ - @backstage/plugin-catalog-node@1.2.2-next.1
26
+ - @backstage/config@1.0.5-next.1
27
+ - @backstage/integration@1.4.1-next.1
28
+ - @backstage/catalog-model@1.1.4-next.1
29
+
3
30
  ## 0.1.5-next.0
4
31
 
5
32
  ### Patch Changes
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # Catalog Backend Module for OpenAPI specifications
1
+ # Catalog Backend Module to resolve $refs in yaml documents
2
2
 
3
- This is an extension module to the plugin-catalog-backend plugin, providing extensions targeted at OpenAPI specifications.
3
+ This is an extension module to the Catalog backend, providing extensions to resolve $refs in yaml documents.
4
4
 
5
- With this you can split your OpenAPI definition into multiple files and reference them. They will be bundled, using an UrlReader, during processing and stored as a single specification.
5
+ With this you can split your yaml documents into multiple files and reference them. They will be bundled, using an UrlReader, during processing and stored as a single specification.
6
+
7
+ This is useful for OpenAPI and AsyncAPI specifications.
6
8
 
7
9
  ## Installation
8
10
 
@@ -15,15 +17,18 @@ yarn add --cwd packages/backend @backstage/plugin-catalog-backend-module-openapi
15
17
 
16
18
  ### Adding the plugin to your `packages/backend`
17
19
 
18
- #### **openApiPlaceholderResolver**
20
+ #### **jsonSchemaRefPlaceholderResolver**
19
21
 
20
- The placeholder resolver can be added by importing `openApiPlaceholderResolver` in `src/plugins/catalog.ts` in your `backend` package and adding the following.
22
+ The placeholder resolver can be added by importing `jsonSchemaRefPlaceholderResolver` in `src/plugins/catalog.ts` in your `backend` package and adding the following.
21
23
 
22
24
  ```ts
23
- builder.setPlaceholderResolver('openapi', openApiPlaceholderResolver);
25
+ builder.setPlaceholderResolver('openapi', jsonSchemaRefPlaceholderResolver);
26
+ builder.setPlaceholderResolver('asyncapi', jsonSchemaRefPlaceholderResolver);
24
27
  ```
25
28
 
26
- This allows you to use the `$openapi` placeholder when referencing your OpenAPI specification. This will then resolve all `$ref` instances in your specification.
29
+ 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.
30
+
31
+ You can also use this resolver for other kind of yaml files to resolve $ref pointer.
27
32
 
28
33
  ```yaml
29
34
  apiVersion: backstage.io/v1alpha1
package/dist/index.cjs.js CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var integration = require('@backstage/integration');
6
- var SwaggerParser = require('@apidevtools/swagger-parser');
5
+ var pluginCatalogNode = require('@backstage/plugin-catalog-node');
6
+ var $RefParser = require('@apidevtools/json-schema-ref-parser');
7
7
  var yaml = require('yaml');
8
8
  var path = require('path');
9
- var pluginCatalogNode = require('@backstage/plugin-catalog-node');
9
+ var integration = require('@backstage/integration');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
12
 
@@ -28,7 +28,7 @@ function _interopNamespace(e) {
28
28
  return Object.freeze(n);
29
29
  }
30
30
 
31
- var SwaggerParser__default = /*#__PURE__*/_interopDefaultLegacy(SwaggerParser);
31
+ var $RefParser__default = /*#__PURE__*/_interopDefaultLegacy($RefParser);
32
32
  var path__namespace = /*#__PURE__*/_interopNamespace(path);
33
33
 
34
34
  const protocolPattern = /^(\w{2,}):\/\//i;
@@ -39,7 +39,7 @@ const getProtocol = (refPath) => {
39
39
  }
40
40
  return void 0;
41
41
  };
42
- async function bundleOpenApiSpecification(specification, baseUrl, read, resolveUrl) {
42
+ async function bundleFileWithRefs(fileWithRefs, baseUrl, read, resolveUrl) {
43
43
  const fileUrlReaderResolver = {
44
44
  canRead: (file) => {
45
45
  const protocol = getProtocol(file.url);
@@ -67,9 +67,56 @@ async function bundleOpenApiSpecification(specification, baseUrl, read, resolveU
67
67
  http: httpUrlReaderResolver
68
68
  }
69
69
  };
70
- const specObject = yaml.parse(specification);
71
- const bundledSpec = await SwaggerParser__default["default"].bundle(specObject, options);
72
- return yaml.stringify(bundledSpec);
70
+ const fileObject = yaml.parse(fileWithRefs);
71
+ const bundledObject = await $RefParser__default["default"].bundle(fileObject, options);
72
+ return yaml.stringify(bundledObject);
73
+ }
74
+
75
+ async function jsonSchemaRefPlaceholderResolver(params) {
76
+ const { content, url } = await readTextLocation(params);
77
+ params.emit(pluginCatalogNode.processingResult.refresh(`url:${url}`));
78
+ try {
79
+ return await bundleFileWithRefs(
80
+ content,
81
+ url,
82
+ params.read,
83
+ params.resolveUrl
84
+ );
85
+ } catch (error) {
86
+ throw new Error(
87
+ `Placeholder $${params.key} unable to bundle the file at ${params.value}, ${error}`
88
+ );
89
+ }
90
+ }
91
+ async function readTextLocation(params) {
92
+ const newUrl = relativeUrl(params);
93
+ try {
94
+ const data = await params.read(newUrl);
95
+ return { content: data.toString("utf-8"), url: newUrl };
96
+ } catch (e) {
97
+ throw new Error(
98
+ `Placeholder $${params.key} could not read location ${params.value}, ${e}`
99
+ );
100
+ }
101
+ }
102
+ function relativeUrl({
103
+ key,
104
+ value,
105
+ baseUrl,
106
+ resolveUrl
107
+ }) {
108
+ if (typeof value !== "string") {
109
+ throw new Error(
110
+ `Placeholder $${key} expected a string value parameter, in the form of an absolute URL or a relative path`
111
+ );
112
+ }
113
+ try {
114
+ return resolveUrl(value, baseUrl);
115
+ } catch (e) {
116
+ throw new Error(
117
+ `Placeholder $${key} could not form a URL out of ${baseUrl} and ${value}, ${e}`
118
+ );
119
+ }
73
120
  }
74
121
 
75
122
  class OpenApiRefProcessor {
@@ -102,7 +149,7 @@ class OpenApiRefProcessor {
102
149
  };
103
150
  this.logger.debug(`Bundling OpenAPI specification from ${location.target}`);
104
151
  try {
105
- const bundledSpec = await bundleOpenApiSpecification(
152
+ const bundledSpec = await bundleFileWithRefs(
106
153
  definition.toString(),
107
154
  location.target,
108
155
  this.reader.read,
@@ -119,53 +166,9 @@ class OpenApiRefProcessor {
119
166
  }
120
167
  }
121
168
 
122
- async function openApiPlaceholderResolver(params) {
123
- const { content, url } = await readTextLocation(params);
124
- params.emit(pluginCatalogNode.processingResult.refresh(`url:${url}`));
125
- try {
126
- return await bundleOpenApiSpecification(
127
- content,
128
- url,
129
- params.read,
130
- params.resolveUrl
131
- );
132
- } catch (error) {
133
- throw new Error(
134
- `Placeholder $${params.key} unable to bundle OpenAPI specification at ${params.value}, ${error}`
135
- );
136
- }
137
- }
138
- async function readTextLocation(params) {
139
- const newUrl = relativeUrl(params);
140
- try {
141
- const data = await params.read(newUrl);
142
- return { content: data.toString("utf-8"), url: newUrl };
143
- } catch (e) {
144
- throw new Error(
145
- `Placeholder $${params.key} could not read location ${params.value}, ${e}`
146
- );
147
- }
148
- }
149
- function relativeUrl({
150
- key,
151
- value,
152
- baseUrl,
153
- resolveUrl
154
- }) {
155
- if (typeof value !== "string") {
156
- throw new Error(
157
- `Placeholder $${key} expected a string value parameter, in the form of an absolute URL or a relative path`
158
- );
159
- }
160
- try {
161
- return resolveUrl(value, baseUrl);
162
- } catch (e) {
163
- throw new Error(
164
- `Placeholder $${key} could not form a URL out of ${baseUrl} and ${value}, ${e}`
165
- );
166
- }
167
- }
169
+ const openApiPlaceholderResolver = jsonSchemaRefPlaceholderResolver;
168
170
 
169
171
  exports.OpenApiRefProcessor = OpenApiRefProcessor;
172
+ exports.jsonSchemaRefPlaceholderResolver = jsonSchemaRefPlaceholderResolver;
170
173
  exports.openApiPlaceholderResolver = openApiPlaceholderResolver;
171
174
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/lib/bundle.ts","../src/OpenApiRefProcessor.ts","../src/openApiPlaceholderResolver.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 SwaggerParser from '@apidevtools/swagger-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 bundleOpenApiSpecification(\n specification: string,\n baseUrl: string,\n read: BundlerRead,\n resolveUrl: BundlerResolveUrl,\n): Promise<string> {\n const fileUrlReaderResolver: SwaggerParser.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: SwaggerParser.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: SwaggerParser.Options = {\n resolve: {\n file: fileUrlReaderResolver,\n http: httpUrlReaderResolver,\n },\n };\n const specObject = parse(specification);\n const bundledSpec = await SwaggerParser.bundle(specObject, options);\n return stringify(bundledSpec);\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 {\n CatalogProcessor,\n LocationSpec,\n} from '@backstage/plugin-catalog-backend';\nimport { bundleOpenApiSpecification } 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 bundledSpec = await bundleOpenApiSpecification(\n definition.toString(),\n location.target,\n this.reader.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 { PlaceholderResolverParams } from '@backstage/plugin-catalog-backend';\nimport { JsonValue } from '@backstage/types';\nimport { processingResult } from '@backstage/plugin-catalog-node';\nimport { bundleOpenApiSpecification } from './lib';\n\n/** @public */\nexport async function openApiPlaceholderResolver(\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 bundleOpenApiSpecification(\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 OpenAPI specification 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"],"names":["path","parse","SwaggerParser","stringify","ScmIntegrations","processingResult"],"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,GAAG,WAAY,EAAA,CAAA;AAAA,GAC9B;AACA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA,CAAA;AAMA,eAAsB,0BACpB,CAAA,aAAA,EACA,OACA,EAAA,IAAA,EACA,UACiB,EAAA;AACjB,EAAA,MAAM,qBAAuD,GAAA;AAAA,IAC3D,SAAS,CAAQ,IAAA,KAAA;AACf,MAAM,MAAA,QAAA,GAAW,WAAY,CAAA,I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,CAAA;AACrC,IAAA,OAAO,EAAE,OAAS,EAAA,IAAA,CAAK,SAAS,OAAO,CAAA,EAAG,KAAK,MAAO,EAAA,CAAA;AAAA,WAC/C,CAAP,EAAA;AACA,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAiB,aAAA,EAAA,MAAA,CAAO,GAA+B,CAAA,yBAAA,EAAA,MAAA,CAAO,KAAU,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AAAA,KAC1E,CAAA;AAAA,GACF;AACF,CAAA;AAEA,SAAS,WAAY,CAAA;AAAA,EACnB,GAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AACF,CAAsC,EAAA;AACpC,EAAI,IAAA,OAAO,UAAU,QAAU,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAiB,aAAA,EAAA,GAAA,CAAA,qFAAA,CAAA;AAAA,KACnB,CAAA;AAAA,GACF;AAEA,EAAI,IAAA;AACF,IAAO,OAAA,UAAA,CAAW,OAAO,OAAO,CAAA,CAAA;AAAA,WACzB,CAAP,EAAA;AAKA,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,aAAA,EAAiB,GAAmC,CAAA,6BAAA,EAAA,OAAA,CAAA,KAAA,EAAe,KAAU,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA;AAAA,KAC/E,CAAA;AAAA,GACF;AACF;;;;;"}
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(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 {\n CatalogProcessor,\n LocationSpec,\n} from '@backstage/plugin-catalog-backend';\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 bundledSpec = await bundleFileWithRefs(\n definition.toString(),\n location.target,\n this.reader.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,CAAA,IAAA,CAAK,OAAO,CAAA,CAAA;AAC1C,EAAA,IAAI,KAAO,EAAA;AACT,IAAO,OAAA,KAAA,CAAM,GAAG,WAAY,EAAA,CAAA;AAAA,GAC9B;AACA,EAAO,OAAA,KAAA,CAAA,CAAA;AACT,CAAA,CAAA;AAMA,eAAsB,kBACpB,CAAA,YAAA,EACA,OACA,EAAA,IAAA,EACA,UACiB,EAAA;AACjB,EAAA,MAAM,qBAAoD,GAAA;AAAA,IACxD,SAAS,CAAQ,IAAA,KAAA;AACf,MAAM,MAAA,QAAA,GAAW,WAAY,CAAA,IAAA,CAAK,GAAG,CAAA,CAAA;AACrC,MAAO,OAAA,QAAA,KAAa,UAAa,QAAa,KAAA,MAAA,CAAA;AAAA,KAChD;AAAA,IACA,IAAA,EAAM,OAAM,IAAQ,KAAA;AAClB,MAAA,MAAM,YAAe,GAAAA,eAAA,CAAK,QAAS,CAAA,GAAA,EAAK,KAAK,GAAG,CAAA,CAAA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K,MAAM,CAAA,CAAA;AAAA,KAChD,CAAA;AAEA,IAAA,IAAA,CAAK,MAAO,CAAA,KAAA,CAAM,CAAuC,oCAAA,EAAA,QAAA,CAAS,MAAQ,CAAA,CAAA,CAAA,CAAA;AAC1E,IAAI,IAAA;AACF,MAAA,MAAM,cAAc,MAAM,kBAAA;AAAA,QACxB,WAAW,QAAS,EAAA;AAAA,QACpB,QAAS,CAAA,MAAA;AAAA,QACT,KAAK,MAAO,CAAA,IAAA;AAAA,QACZ,UAAA;AAAA,OACF,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,GAAG,MAAA;AAAA,QACH,MAAM,EAAE,GAAG,MAAO,CAAA,IAAA,EAAM,YAAY,WAAY,EAAA;AAAA,OAClD,CAAA;AAAA,aACO,KAAP,EAAA;AACA,MAAK,IAAA,CAAA,MAAA,CAAO,KAAM,CAAA,CAAA,sCAAA,CAAA,EAA0C,KAAK,CAAA,CAAA;AACjE,MAAO,OAAA,MAAA,CAAA;AAAA,KACT;AAAA,GACF;AACF;;AC/EO,MAAM,0BAA6B,GAAA;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
+ import { PlaceholderResolverParams, CatalogProcessor, LocationSpec } from '@backstage/plugin-catalog-backend';
2
+ import { JsonValue } from '@backstage/types';
1
3
  import { UrlReader } from '@backstage/backend-common';
2
4
  import { Entity } from '@backstage/catalog-model';
3
5
  import { Config } from '@backstage/config';
4
6
  import { ScmIntegrations } from '@backstage/integration';
5
- import { CatalogProcessor, LocationSpec, PlaceholderResolverParams } from '@backstage/plugin-catalog-backend';
6
7
  import { Logger } from 'winston';
7
- import { JsonValue } from '@backstage/types';
8
+
9
+ /** @public */
10
+ declare function jsonSchemaRefPlaceholderResolver(params: PlaceholderResolverParams): Promise<JsonValue>;
8
11
 
9
12
  /**
10
13
  * @public
@@ -27,7 +30,10 @@ declare class OpenApiRefProcessor implements CatalogProcessor {
27
30
  preProcessEntity(entity: Entity, location: LocationSpec): Promise<Entity>;
28
31
  }
29
32
 
30
- /** @public */
31
- declare function openApiPlaceholderResolver(params: PlaceholderResolverParams): Promise<JsonValue>;
33
+ /**
34
+ * @public
35
+ * @deprecated replaced by jsonSchemaRefPlaceholderResolver
36
+ */
37
+ declare const openApiPlaceholderResolver: typeof jsonSchemaRefPlaceholderResolver;
32
38
 
33
- export { OpenApiRefProcessor, openApiPlaceholderResolver };
39
+ export { OpenApiRefProcessor, 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.5-next.0",
4
+ "version": "0.1.5-next.2",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -32,20 +32,20 @@
32
32
  "start": "backstage-cli package start"
33
33
  },
34
34
  "dependencies": {
35
- "@apidevtools/swagger-parser": "^10.1.0",
36
- "@backstage/backend-common": "^0.16.1-next.0",
37
- "@backstage/catalog-model": "^1.1.4-next.0",
38
- "@backstage/config": "^1.0.5-next.0",
39
- "@backstage/integration": "^1.4.1-next.0",
40
- "@backstage/plugin-catalog-backend": "^1.6.0-next.0",
41
- "@backstage/plugin-catalog-node": "^1.2.2-next.0",
42
- "@backstage/types": "^1.0.2-next.0",
35
+ "@apidevtools/json-schema-ref-parser": "^9.0.6",
36
+ "@backstage/backend-common": "^0.17.0-next.2",
37
+ "@backstage/catalog-model": "^1.1.4-next.1",
38
+ "@backstage/config": "^1.0.5-next.1",
39
+ "@backstage/integration": "^1.4.1-next.1",
40
+ "@backstage/plugin-catalog-backend": "^1.6.0-next.2",
41
+ "@backstage/plugin-catalog-node": "^1.3.0-next.2",
42
+ "@backstage/types": "^1.0.2-next.1",
43
43
  "winston": "^3.2.1",
44
44
  "yaml": "^2.1.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@backstage/backend-test-utils": "^0.1.31-next.0",
48
- "@backstage/cli": "^0.21.2-next.0",
47
+ "@backstage/backend-test-utils": "^0.1.31-next.2",
48
+ "@backstage/cli": "^0.21.2-next.2",
49
49
  "openapi-types": "^12.0.0"
50
50
  },
51
51
  "files": [