@platformatic/service 1.15.0 → 1.16.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/index.js CHANGED
@@ -21,11 +21,11 @@ const { addLoggerToTheConfig } = require('./lib/utils')
21
21
  const { start, buildServer } = require('./lib/start')
22
22
  const ServiceGenerator = require('./lib/generator/service-generator.js')
23
23
 
24
- // TODO(mcollina): toLoad is deprecated, remove it in the next major version.
25
- async function platformaticService (app, opts, toLoad) {
24
+ // TODO(mcollina): arugments[2] is deprecated, remove it in the next major version.
25
+ async function platformaticService (app, opts) {
26
26
  const configManager = app.platformatic.configManager
27
27
  const config = configManager.current
28
- const beforePlugins = opts.beforePlugins || toLoad || []
28
+ const beforePlugins = opts.beforePlugins || arguments[2] || []
29
29
 
30
30
  if (isKeyEnabled('metrics', config)) {
31
31
  app.register(setupMetrics, config.metrics)
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const Swagger = require('@fastify/swagger')
4
- const SwaggerUI = require('@fastify/swagger-ui')
4
+ const ScalarApiReference = require('@scalar/fastify-api-reference')
5
5
  const deepmerge = require('@fastify/deepmerge')({ all: true })
6
6
  const fp = require('fastify-plugin')
7
7
 
@@ -54,12 +54,20 @@ async function setupOpenAPI (app, opts) {
54
54
 
55
55
  await app.register(Swagger, swaggerOptions)
56
56
 
57
- const { default: theme } = await import('@platformatic/swagger-ui-theme')
58
- app.register(SwaggerUI, {
59
- ...theme,
57
+ const { default: scalarTheme } = await import('@platformatic/scalar-theme')
58
+ const routePrefix = openapi.swaggerPrefix || '/documentation'
59
+
60
+ /** Serve spec file in yaml and json */
61
+ app.get(`${routePrefix}/json`, { schema: { hide: true } }, async () => app.swagger())
62
+ app.get(`${routePrefix}/yaml`, { schema: { hide: true } }, async () => app.swagger({ yaml: true }))
63
+
64
+ app.register(ScalarApiReference, {
65
+ ...opts,
60
66
  ...openapi,
61
- logLevel: 'warn',
62
- prefix: openapi.swaggerPrefix || '/documentation'
67
+ routePrefix,
68
+ configuration: {
69
+ customCss: scalarTheme.theme
70
+ }
63
71
  })
64
72
  }
65
73
 
@@ -13,7 +13,7 @@ const {
13
13
  const wrapperPath = join(__dirname, 'sandbox-wrapper.js')
14
14
 
15
15
  const Swagger = require('@fastify/swagger')
16
- const SwaggerUI = require('@fastify/swagger-ui')
16
+ const ScalarApiReference = require('@scalar/fastify-api-reference')
17
17
 
18
18
  async function loadVersions (app) {
19
19
  const configManager = app.platformatic.configManager
@@ -44,9 +44,12 @@ async function loadVersions (app) {
44
44
  }
45
45
  })
46
46
 
47
- app.register(SwaggerUI, {
47
+ app.get('/documentation/json', { schema: { hide: true } }, async () => app.swagger())
48
+ app.get('/documentation/yaml', { schema: { hide: true } }, async () => app.swagger({ yaml: true }))
49
+
50
+ app.register(ScalarApiReference, {
48
51
  logLevel: 'warn',
49
- prefix: '/documentation'
52
+ routePrefix: '/documentation'
50
53
  })
51
54
 
52
55
  if (latestVersionConfig.plugins) {
@@ -110,9 +113,12 @@ async function loadVersions (app) {
110
113
  }
111
114
  })
112
115
 
113
- app.register(SwaggerUI, {
116
+ app.get('/documentation/json', { schema: { hide: true } }, async () => app.swagger())
117
+ app.get('/documentation/yaml', { schema: { hide: true } }, async () => app.swagger({ yaml: true }))
118
+
119
+ app.register(ScalarApiReference, {
114
120
  logLevel: 'warn',
115
- prefix: '/documentation'
121
+ routePrefix: '/documentation'
116
122
  })
117
123
 
118
124
  const componentSchemas = prevOpenapiSchema.components?.schemas ?? {}
@@ -222,6 +222,9 @@
222
222
  <script>
223
223
  const currentPath = window.location.pathname
224
224
 
225
+ const openApiLink = document.getElementById('openapi-link')
226
+ openApiLink.href = currentPath + 'documentation'
227
+
225
228
  const graphqlLink = document.getElementById('graphql-link')
226
229
  graphqlLink.href = currentPath + 'graphiql'
227
230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -48,42 +48,42 @@
48
48
  "@fastify/restartable": "^2.1.1",
49
49
  "@fastify/static": "^6.11.2",
50
50
  "@fastify/swagger": "^8.10.1",
51
- "@fastify/swagger-ui": "^2.0.0",
52
51
  "@fastify/under-pressure": "^8.3.0",
53
52
  "@mercuriusjs/federation": "^2.0.0",
53
+ "@scalar/fastify-api-reference": "^1.10.1",
54
54
  "@types/ws": "^8.5.6",
55
55
  "ajv": "^8.12.0",
56
+ "cli-progress": "^3.12.0",
56
57
  "close-with-grace": "^1.2.0",
57
58
  "code-block-writer": "^12.0.0",
58
- "commist": "^3.2.0",
59
59
  "colorette": "^2.0.20",
60
- "cli-progress": "^3.12.0",
60
+ "commist": "^3.2.0",
61
61
  "desm": "^1.3.0",
62
62
  "env-schema": "^5.2.0",
63
63
  "es-main": "^1.3.0",
64
64
  "execa": "^8.0.1",
65
65
  "fastify": "^4.23.2",
66
- "fastify-openapi-glue": "^4.3.3",
67
66
  "fastify-metrics": "^10.3.2",
67
+ "fastify-openapi-glue": "^4.3.3",
68
68
  "fastify-plugin": "^4.5.1",
69
69
  "graphql": "^16.8.1",
70
- "help-me": "^4.2.0",
70
+ "help-me": "^5.0.0",
71
71
  "mercurius": "^13.1.0",
72
72
  "minimist": "^1.2.8",
73
73
  "openapi-schema-diff": "^0.0.1",
74
74
  "pino": "^8.15.3",
75
75
  "pino-pretty": "^10.2.0",
76
76
  "rfdc": "^1.3.0",
77
- "undici": "^6.0.0",
78
77
  "ua-parser-js": "^1.0.36",
79
- "@platformatic/client": "1.15.0",
80
- "@platformatic/config": "1.15.0",
81
- "@platformatic/authenticate": "1.15.0",
82
- "@platformatic/generators": "1.15.0",
83
- "@platformatic/swagger-ui-theme": "1.15.0",
84
- "@platformatic/telemetry": "1.15.0",
85
- "@platformatic/metaconfig": "1.15.0",
86
- "@platformatic/utils": "1.15.0"
78
+ "undici": "^6.0.0",
79
+ "@platformatic/authenticate": "1.16.0",
80
+ "@platformatic/config": "1.16.0",
81
+ "@platformatic/generators": "1.16.0",
82
+ "@platformatic/scalar-theme": "1.16.0",
83
+ "@platformatic/telemetry": "1.16.0",
84
+ "@platformatic/utils": "1.16.0",
85
+ "@platformatic/client": "1.16.0",
86
+ "@platformatic/metaconfig": "1.16.0"
87
87
  },
88
88
  "standard": {
89
89
  "ignore": [
@@ -98,7 +98,7 @@
98
98
  ]
99
99
  },
100
100
  "scripts": {
101
- "test": "pnpm run lint && c8 -x fixtures -x test node ./test/runner.js && tsd",
101
+ "test": "pnpm run lint && node ./test/runner.js && tsd",
102
102
  "nocov": "pnpm run lint && node ./test/runner.js && tsd",
103
103
  "build": "node lib/schema.js | json2ts > config.d.ts",
104
104
  "lint": "standard | snazzy && ts-standard | snazzy"