Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/add-new-frontend-system-support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@dweber019/backstage-plugin-api-docs-spectral-linter': minor
---

Added support for the new frontend system.

A new `/alpha` entry point is now available that exports the plugin as a default export compatible with `createFrontendPlugin`. This includes:

- `ApiBlueprint` for the Spectral Linter API
- `EntityContentBlueprint` for the Spectral Linter tab on API entity pages
- Entity filter that automatically shows the tab only on `openapi` and `asyncapi` API entities

The existing entry point (`/`) remains unchanged for backward compatibility.
29 changes: 28 additions & 1 deletion plugins/api-docs-spectral-linter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,36 @@
"version": "0.5.2",
"main": "src/index.ts",
"types": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha.tsx",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha.tsx"
],
"package.json": [
"package.json"
]
}
},
"publishConfig": {
"access": "public",
"main": "dist/index.esm.js",
"types": "dist/index.d.ts"
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.esm.js"
},
"./alpha": {
"types": "./dist/alpha.d.ts",
"default": "./dist/alpha.esm.js"
},
"./package.json": "./package.json"
}
},
"backstage": {
"role": "frontend-plugin",
Expand All @@ -36,6 +62,7 @@
"@backstage/catalog-model": "^1.7.6",
"@backstage/core-components": "^0.18.4",
"@backstage/core-plugin-api": "^1.12.1",
"@backstage/frontend-plugin-api": "^0.13.2",
"@backstage/plugin-catalog-react": "^1.21.4",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
Expand Down
22 changes: 22 additions & 0 deletions plugins/api-docs-spectral-linter/src/alpha.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import plugin from './alpha';

describe('spectral linter new frontend system', () => {
it('should export the plugin as default', () => {
expect(plugin).toBeDefined();
});
});
63 changes: 63 additions & 0 deletions plugins/api-docs-spectral-linter/src/alpha.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
ApiBlueprint,
configApiRef,
createFrontendPlugin,
} from '@backstage/frontend-plugin-api';
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
import { linterApiRef, LinterClient } from './api';
import { isApiDocsSpectralLinterAvailable } from './lib/helper';

/**
* Provides the Spectral Linter API as an extension.
* @alpha
*/
const spectralLinterApi = ApiBlueprint.make({
params: defineParams =>
defineParams({
api: linterApiRef,
deps: { configApi: configApiRef },
factory: ({ configApi }) => new LinterClient({ configApi }),
}),
});

/**
* Entity content extension that renders the Spectral Linter tab on API entity pages.
* @alpha
*/
const spectralLinterContent = EntityContentBlueprint.make({
name: 'spectral-linter',
params: {
path: '/spectral-linter',
title: 'Spectral Linter',
filter: entity => isApiDocsSpectralLinterAvailable(entity),
loader: () =>
import('./components/EntityApiDocsSpectralLinterContent').then(m => (
<m.EntityApiDocsSpectralLinterContent />
)),
},
});

/**
* The API docs spectral linter plugin, for use with the new frontend system.
* @alpha
*/
export default createFrontendPlugin({
pluginId: 'api-docs-spectral-linter',
extensions: [spectralLinterApi, spectralLinterContent],
});
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4899,6 +4899,7 @@ __metadata:
"@backstage/core-components": "npm:^0.18.4"
"@backstage/core-plugin-api": "npm:^1.12.1"
"@backstage/dev-utils": "npm:^1.1.18"
"@backstage/frontend-plugin-api": "npm:^0.13.2"
"@backstage/plugin-catalog-react": "npm:^1.21.4"
"@backstage/test-utils": "npm:^1.7.14"
"@material-ui/core": "npm:^4.12.2"
Expand Down