Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# AsyncAPI 2.x.x remote absolute URI
# REACT_APP_DEFINITION_URL=https://raw.githubusercontent.com/asyncapi/spec/v2.6.0/examples/streetlights-kafka.yml

# Swagger 2.0 to OpenAPI 3.0.x Converter URL
# Set this to use a custom converter service instead of the default
# Set to 'null' (without quotes) to disable the converter feature
# REACT_APP_SWAGGER2_CONVERTER_URL=https://converter.swagger.io/api/convert

REACT_APP_VERSION=$npm_package_version

REACT_APP_APIDOM_WORKER_PATH=./src/plugins/editor-monaco-language-apidom/language/apidom.worker.js
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,12 @@ These environment variables will get baked in during build time into build artif

Environment variables currently available:

| Variable name | Description |
|-----------------------------|:----------------------------------------------------------------------------------------------------------:|
| `REACT_APP_DEFINITION_FILE` | Specifies a local file path, and the specified file must also be present in the `/public/static` directory |
| `REACT_APP_DEFINITION_URL` | Specifies a remote URL. This environment variable currently takes precedence over `REACT_APP_SWAGGER_FILE` |
| `REACT_APP_VERSION` | Specifies the version of this app. The version is read from `package.json` file. |
| Variable name | Description |
|--------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------:|
| `REACT_APP_DEFINITION_FILE` | Specifies a local file path, and the specified file must also be present in the `/public/static` directory |
| `REACT_APP_DEFINITION_URL` | Specifies a remote URL. This environment variable currently takes precedence over `REACT_APP_SWAGGER_FILE` |
| `REACT_APP_SWAGGER2_CONVERTER_URL` | Endpoint to use for converting OpenAPI 2.x specifications to OpenAPI 3.x. Default is `https://converter.swagger.io/api/convert`. |
| `REACT_APP_VERSION` | Specifies the version of this app. The version is read from `package.json` file. |

Sample environment variable values can be found in `.env` file. For more information about using
environment variables, please refer to [adding Custom Environment Variables](https://create-react-app.dev/docs/adding-custom-environment-variables/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ const ConvertToOpenAPI30xMenuItem = ({
}) => {
const DropdownMenuItem = getComponent('DropdownMenuItem');
const isContentTypeOpenAPI20 = editorSelectors.selectIsContentTypeOpenAPI20();
const converterURL = editorSelectors.selectOpenAPI20ConverterURL();

return isContentTypeOpenAPI20 ? (
return isContentTypeOpenAPI20 && converterURL ? (
<DropdownMenuItem onClick={onClick}>{children || 'Convert to OpenAPI 3.0.x'}</DropdownMenuItem>
) : null;
};
Expand All @@ -18,6 +19,7 @@ ConvertToOpenAPI30xMenuItem.propTypes = {
getComponent: PropTypes.func.isRequired,
editorSelectors: PropTypes.shape({
selectIsContentTypeOpenAPI20: PropTypes.func.isRequired,
selectOpenAPI20ConverterURL: PropTypes.func.isRequired,
}).isRequired,
children: PropTypes.node,
onClick: PropTypes.func.isRequired,
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/top-bar/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { SUCCESS_STATUS, IDLE_STATUS } from './reducers.js';
* editor state plugin selectors.
*/

export const selectOpenAPI20ConverterURL = () => 'https://converter.swagger.io/api/convert';
export const selectOpenAPI20ConverterURL = () => {
const converterUrl = process.env.REACT_APP_SWAGGER2_CONVERTER_URL;
if (converterUrl === 'null') {
return null;
}
return converterUrl || 'https://converter.swagger.io/api/convert';
};

/**
* editorTopBar state plugin selectors.
Expand Down