@openaddresses/batch-schema 9.3.0 → 9.4.0

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
@@ -10,6 +10,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v9.4.0
14
+
15
+ - :rocket: Add support for `private` key which will hide endpoint in swagger
16
+
13
17
  ### v9.3.0
14
18
 
15
19
  - :rocket: Coerce types on output
package/lib/openapi.js CHANGED
@@ -31,66 +31,68 @@ export default class Docs {
31
31
  path = path.join('/');
32
32
 
33
33
 
34
- if (!this.base.paths[path]) this.base.paths[path] = {};
34
+ if (!schemas.private) {
35
+ if (!this.base.paths[path]) this.base.paths[path] = {};
35
36
 
36
- if (this.base.paths[path][method]) throw new Error(`Duplicate Path: ${parsed.join(' ')}`);
37
+ if (this.base.paths[path][method]) throw new Error(`Duplicate Path: ${parsed.join(' ')}`);
37
38
 
38
- const document = {
39
- summary: schemas.description || 'No Description',
40
- tags: [schemas.group || 'Default'],
41
- parameters: [],
42
- responses: {
43
- 200: {
44
- description: 'Successful Response'
39
+ const document = {
40
+ summary: schemas.description || 'No Description',
41
+ tags: [schemas.group || 'Default'],
42
+ parameters: [],
43
+ responses: {
44
+ 200: {
45
+ description: 'Successful Response'
46
+ }
45
47
  }
46
- }
47
- };
48
-
49
- for (const key in schemas) {
50
- if (key[0] === ':') {
51
- document.parameters.push({
52
- in: 'path',
53
- name: key,
54
- schema: {
55
- type: schemas[key]
56
- },
57
- required: true
58
- });
59
- }
60
- }
48
+ };
61
49
 
62
- if (schemas.query && schemas.query.type === 'object') {
63
- for (const name in (schemas.query.properties || {})) {
64
- const query = schemas.query.properties[name];
65
- document.parameters.push({
66
- in: 'query',
67
- name,
68
- schema: query,
69
- required: query.required || (schemas.query.required || []).includes(name),
70
- description: query.description || 'No Description'
71
- });
50
+ for (const key in schemas) {
51
+ if (key[0] === ':') {
52
+ document.parameters.push({
53
+ in: 'path',
54
+ name: key,
55
+ schema: {
56
+ type: schemas[key]
57
+ },
58
+ required: true
59
+ });
60
+ }
72
61
  }
73
- }
74
62
 
75
- if (schemas.res) {
76
- document.responses['200'].content = {
77
- 'application/json': {
78
- schema: schemas.res
63
+ if (schemas.query && schemas.query.type === 'object') {
64
+ for (const name in (schemas.query.properties || {})) {
65
+ const query = schemas.query.properties[name];
66
+ document.parameters.push({
67
+ in: 'query',
68
+ name,
69
+ schema: query,
70
+ required: query.required || (schemas.query.required || []).includes(name),
71
+ description: query.description || 'No Description'
72
+ });
79
73
  }
80
- };
81
- }
74
+ }
82
75
 
83
- if (schemas.body) {
84
- document.requestBody = {
85
- required: true,
86
- content: {
76
+ if (schemas.res) {
77
+ document.responses['200'].content = {
87
78
  'application/json': {
88
- schema: schemas.body
79
+ schema: schemas.res
89
80
  }
90
- }
91
- };
92
- }
81
+ };
82
+ }
93
83
 
94
- this.base.paths[path][method] = document;
84
+ if (schemas.body) {
85
+ document.requestBody = {
86
+ required: true,
87
+ content: {
88
+ 'application/json': {
89
+ schema: schemas.body
90
+ }
91
+ }
92
+ };
93
+ }
94
+
95
+ this.base.paths[path][method] = document;
96
+ }
95
97
  }
96
98
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "root": true,
5
5
  "main": "index.js",
6
- "version": "9.3.0",
6
+ "version": "9.4.0",
7
7
  "description": "Strongly Validated JSON Schema support for address",
8
8
  "repository": "git@github.com:openaddresses/batch-schema",
9
9
  "author": "ingalls <nick@ingalls.ca>",