@superhero/http-server-using-oas 4.7.11 → 4.7.13

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
@@ -1,3 +1,15 @@
1
+ ---
2
+ #### v4.7.13
3
+ ---
4
+
5
+ Added support for a bootstrap process that builds routes automatically if an or field is defined
6
+
7
+ ---
8
+ #### v4.7.12
9
+ ---
10
+
11
+ Bugfix route operation access - forgot to test last version.
12
+
1
13
  ---
2
14
  #### v4.7.11
3
15
  ---
package/config.json CHANGED
@@ -14,6 +14,11 @@
14
14
  "@superhero/http-server"
15
15
  ]
16
16
  },
17
+ "@superhero/http-server-using-oas/oas-to-routes":
18
+ {
19
+ "path": "./oas-to-routes.js",
20
+ "uses": [ "@superhero/http-server-using-oas" ]
21
+ },
17
22
  "@superhero/http-server-using-oas/dispatcher/options":
18
23
  {
19
24
  "path": "./dispatcher/options.js",
package/index.js CHANGED
@@ -81,9 +81,9 @@ export default class HttpServerUsingOas
81
81
  route['condition.method'] = method
82
82
  route.conditions.push('@superhero/http-server/condition/upstream/method')
83
83
 
84
- if(operation.requestBody?.content)
84
+ if(route.operation.requestBody?.content)
85
85
  {
86
- const supportedContentTypes = Object.keys(operation.requestBody.content)
86
+ const supportedContentTypes = Object.keys(route.operation.requestBody.content)
87
87
  route['condition.content-type'] = supportedContentTypes
88
88
 
89
89
  for(const supportedContentType of supportedContentTypes)
@@ -0,0 +1,29 @@
1
+ export function locate(locator)
2
+ {
3
+ const router = locator.locate('@superhero/http-server-using-oas')
4
+ return new OasToRoutes(router)
5
+ }
6
+
7
+ export default class OasToRoutes
8
+ {
9
+ constructor(router)
10
+ {
11
+ this.router = router
12
+ }
13
+
14
+ bootstrap()
15
+ {
16
+ for(const [ path, operations ] of Object.entries(this.oas.paths))
17
+ {
18
+ for(const [ method, operation ] of Object.entries(operations))
19
+ {
20
+ const dispatcher = operation['operationId'] ?? operation['x-dispatcher']
21
+
22
+ if('string' === typeof dispatcher)
23
+ {
24
+ this.router.setOasRoute(path, method, dispatcher, operation['x-middlewares'] ?? [])
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/http-server-using-oas",
3
- "version": "4.7.11",
3
+ "version": "4.7.13",
4
4
  "description": "Integrates the HTTP server and OAS (OpenAPI Specification) @superhero components",
5
5
  "keywords": [
6
6
  "HTTP 2.0",
@@ -14,6 +14,7 @@
14
14
  "type": "module",
15
15
  "exports": {
16
16
  ".": "./index.js",
17
+ "./oas-to-routes": "./oas-to-routes.js",
17
18
  "./dispatcher/*": "./dispatcher/*.js",
18
19
  "./dispatcher/downstream/*": "./dispatcher/downstream/*.js",
19
20
  "./dispatcher/upstream/*": "./dispatcher/upstream/*.js"
@@ -23,14 +24,14 @@
23
24
  "test": "syntax-check; node --test --test-reporter=@superhero/audit/reporter --experimental-test-coverage"
24
25
  },
25
26
  "dependencies": {
26
- "@superhero/oas": "4.7.11",
27
- "@superhero/http-server": "4.7.11"
27
+ "@superhero/oas": "4.7.13",
28
+ "@superhero/http-server": "4.7.13"
28
29
  },
29
30
  "devDependencies": {
30
- "@superhero/audit": "4.7.11",
31
+ "@superhero/audit": "4.7.13",
31
32
  "@superhero/syntax-check": "0.0.2",
32
- "@superhero/http-request": "4.7.11",
33
- "@superhero/core": "4.7.11"
33
+ "@superhero/http-request": "4.7.13",
34
+ "@superhero/core": "4.7.13"
34
35
  },
35
36
  "author": {
36
37
  "name": "Erik Landvall",