swagger-api-hub
Advanced tools
Comparing version 1.0.0 to 1.1.0-alpha.1
@@ -32,9 +32,13 @@ var __create = Object.create; | ||
var program = new import_commander.default.Command(); | ||
process.title = "swagger-api-hub-cli"; | ||
program.name(Object.keys(import_package.default.bin)[0]).description("Generate front-end interface code to interact with OpenAPI-based backend services").usage("[options] [config-path]").argument( | ||
"[config-path]", | ||
"Path to the configuration file, if not specified, the default configuration file will be used", | ||
"Path to the configuration file, if not specified, the default file path will be used", | ||
"./swagger-api-hub.config.ts" | ||
).helpOption("-h, --help").version(import_package.default.version, "-v, --version").action(async (configPath) => { | ||
const absPath = (0, import_path.resolve)(configPath); | ||
let absPath; | ||
try { | ||
absPath = require.resolve(configPath); | ||
} catch (error) { | ||
absPath = (0, import_path.resolve)(configPath); | ||
} | ||
if (!(0, import_fs.existsSync)(absPath)) { | ||
@@ -46,3 +50,3 @@ import_signale.default.fatal("Config file not found:", configPath); | ||
try { | ||
const originalConfig = require((0, import_path.resolve)(configPath)); | ||
const originalConfig = require(absPath); | ||
config = (originalConfig == null ? void 0 : originalConfig.default) ?? originalConfig; | ||
@@ -49,0 +53,0 @@ } catch (error) { |
{ | ||
"name": "swagger-api-hub", | ||
"version": "1.0.0", | ||
"version": "1.1.0-alpha.1", | ||
"description": "Generate front-end access code for swagger backend services in one click", | ||
@@ -21,3 +21,4 @@ "keywords": [ | ||
"author": "李凤宝 <shijistar@gmail.com>", | ||
"main": "index.js", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"bin": { | ||
@@ -24,0 +25,0 @@ "swagger-api-hub": "./bin/swagger-api-hub.js" |
@@ -33,4 +33,6 @@ # swagger-api-hub | ||
The configuration file should export an array of `ServiceConfig` objects. If you export only one object, it will generate the code directly without prompting. The config file extension can be `.ts`, `.js`, `.json`, or any other module types supported by Node.js. | ||
The configuration file should export an array of `ServiceConfig` objects. If you export only one object, it will generate the code directly without prompting. | ||
The config file can be either local path or npm module path, and the file extension can be `.ts`, `.js`, `.json`, or any other module types supported by Node.js. | ||
The file should look like this: | ||
@@ -65,3 +67,3 @@ | ||
- `name`: A human-readable name for the service. | ||
- `url`: _[required]_ The URL of the OpenAPI specification file. If you have a local file, you can use `input` instead of `url` to specify the file path. Or you can even use `spec` to provide the OpenAPI specification object directly. Either `url`, `input`, or `spec` is required. | ||
- `url`: _[required]_ The URL of the OpenAPI specification file. If you have a local file, you can use `input` instead of `url` to specify the file path. Or you can even use `spec` to provide the OpenAPI specification object directly. Either url, input, or spec is required. | ||
- `apiBase`: The base path of all API endpoints. The service may be hosted on a subpath of the main domain, e.g., _/public-api/iam/v3_, then the apiBase is _/public-api_ in this case. If the original api path from the OpenAPI specification is acceptable, you don't need this field. | ||
@@ -68,0 +70,0 @@ - `crossOrigin`: Whether to use the absolute api path when calling the service. This is useful when the service is hosted on a different domain and you need to set the `Access-Control-Allow-Origin` header. Default is `false`. |
Sorry, the diff of this file is not supported yet
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
38793
25
329
0
87
1
5
1