openapi-sync 1.0.8 → 1.0.9

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/README.md CHANGED
@@ -1,11 +1,37 @@
1
- ## Install Openapi-sync
1
+ # Openapi-sync
2
2
 
3
- `npm i openapi-sync`
3
+ **Openapi-sync** leverages the power of OpenAPI schemas, just like Swagger UI, Postman, Redoc, and other popular tools. This package automates the creation of endpoint URIs and all defined types (including shared types) in a simple and developer-friendly manner and ensures your API remains up-to-date by checking for updates at intervals or right before committing your code (pre-commit).
4
4
 
5
- ## Add a Openapi-sync config file
5
+ ## Installation
6
6
 
7
- Add a `openapi.sync.json` file at the root of your project (check out `openapi.sync.sample.json`)
7
+ To install `openapi-sync`, run the following command:
8
8
 
9
- ## Run `openapi-sync`
9
+ ```bash
10
+ npm install openapi-sync
11
+ ```
10
12
 
11
- Run `openapi-sync` in terminal to start (you can also add it as a script in package.json)
13
+ ## Configuration
14
+
15
+ Create an `openapi.sync.json` file at the root of your project to configure openapi-sync. You can use the provided `openapi.sync.sample.json` as a reference.
16
+
17
+ ## Usage
18
+
19
+ To start using openapi-sync, simply run the following command in your terminal:
20
+
21
+ ```bash
22
+ npx openapi-sync
23
+ ```
24
+
25
+ You can also add it as a script in your package.json for easy access:
26
+
27
+ ```bash
28
+ "scripts": {
29
+ "api-sync": "openapi-sync",
30
+ }
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - Endpoint URI Generation: Automatically generate endpoint URIs from your OpenAPI schema.
36
+ - Types Generation: Generate all defined types, including shared types, from your OpenAPI schema.
37
+ - CLI Commands: Use the command-line interface to regenerate files at any time—on app start, pre-commit, or whenever needed.
@@ -28,8 +28,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.parseSchemaToType = exports.getEndpointDetails = exports.getSharedComponentName = exports.capitalize = exports.yamlStringToJson = exports.isYamlString = exports.isJson = void 0;
30
30
  const regex_1 = require("./regex");
31
- const property_expr_1 = __importDefault(require("property-expr"));
32
31
  const yaml = __importStar(require("js-yaml"));
32
+ const lodash_1 = __importDefault(require("lodash"));
33
33
  const isJson = (value) => {
34
34
  return ["object"].includes(typeof value) && !(value instanceof Blob);
35
35
  };
@@ -100,7 +100,7 @@ const parseSchemaToType = (apiDoc, schema, name, isRequired, options) => {
100
100
  let pathToComponentParts = (schema.$ref || "").split("/");
101
101
  pathToComponentParts.shift();
102
102
  const pathToComponent = pathToComponentParts.join(".");
103
- const component = property_expr_1.default.getter(pathToComponent)(apiDoc);
103
+ const component = lodash_1.default.get(apiDoc, pathToComponent, null);
104
104
  if (component) {
105
105
  const componentName = pathToComponentParts[pathToComponentParts.length - 1];
106
106
  // Reference component via import instead of parsing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "sync openapi variables",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,24 +17,24 @@
17
17
  "scripts": {
18
18
  "test": "echo \"Error: no test specified\"",
19
19
  "build": "tsc",
20
- "publish": "npm run build npm version patch npm publish",
20
+ "publish-package": "npm run build && npm version patch && npm publish",
21
21
  "start": "ts-node index.ts"
22
22
  },
23
23
  "author": "P-Technologies",
24
24
  "license": "ISC",
25
- "devDependencies": {},
26
- "dependencies": {
25
+ "devDependencies": {
27
26
  "@types/js-yaml": "^4.0.9",
28
27
  "@types/lodash": "^4.17.7",
29
28
  "@types/node": "^22.1.0",
30
29
  "ts-node": "^10.9.2",
31
- "typescript": "^5.5.4",
30
+ "typescript": "^5.5.4"
31
+ },
32
+ "dependencies": {
32
33
  "@redocly/openapi-core": "^1.19.0",
33
34
  "axios": "^1.7.3",
34
35
  "axios-retry": "^4.5.0",
35
36
  "dotenv": "^16.4.5",
36
37
  "js-yaml": "^4.1.0",
37
- "lodash": "^4.17.21",
38
- "property-expr": "^2.0.6"
38
+ "lodash": "^4.17.21"
39
39
  }
40
40
  }