@platformatic/sql-openapi 3.41.0 → 3.43.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.d.ts CHANGED
@@ -16,6 +16,10 @@ export interface SQLOpenApiPluginOptions extends Partial<OpenAPIV3.Document> {
16
16
  [fieldName: string]: boolean
17
17
  } | boolean
18
18
  },
19
+ /**
20
+ * Set true to disable all reverse relationship and FK-navigation routes.
21
+ */
22
+ ignoreAllReverseRoutes?: boolean,
19
23
  }
20
24
 
21
25
  declare const plugin: FastifyPluginAsync<SQLOpenApiPluginOptions>
package/index.js CHANGED
@@ -38,6 +38,7 @@ async function setupOpenAPI (app, opts) {
38
38
  const ignore = opts.ignore || []
39
39
  const include = opts.include || []
40
40
  const ignoreRoutes = opts.ignoreRoutes || []
41
+ const ignoreAllReverseRoutes = opts.ignoreAllReverseRoutes || false
41
42
  const paths = opts.paths || {}
42
43
 
43
44
  const { default: scalarTheme } = await import('@platformatic/scalar-theme')
@@ -140,7 +141,8 @@ async function setupOpenAPI (app, opts) {
140
141
  entity,
141
142
  prefix: localPrefix,
142
143
  ignore: ignore[entity.singularName] || {},
143
- ignoreRoutes
144
+ ignoreRoutes,
145
+ ignoreAllReverseRoutes
144
146
  })
145
147
  } else {
146
148
  // TODO support ignore
@@ -148,7 +150,8 @@ async function setupOpenAPI (app, opts) {
148
150
  entity,
149
151
  prefix: localPrefix,
150
152
  ignore,
151
- ignoreRoutes
153
+ ignoreRoutes,
154
+ ignoreAllReverseRoutes
152
155
  })
153
156
  }
154
157
  }
@@ -46,6 +46,7 @@ export async function entityPlugin (app, opts) {
46
46
  const entity = opts.entity
47
47
  const ignore = opts.ignore
48
48
  const ignoreRoutes = opts.ignoreRoutes
49
+ const ignoreAllReverseRoutes = opts.ignoreAllReverseRoutes || false
49
50
 
50
51
  const entitySchema = {
51
52
  $ref: entity.name + '#'
@@ -173,7 +174,7 @@ export async function entityPlugin (app, opts) {
173
174
  return ignoreRoute.path === reverseOpenapiPath && ignoreRoute.method === 'GET'
174
175
  })
175
176
 
176
- if (!ignoredReversedGETRoute) {
177
+ if (!ignoredReversedGETRoute && !ignoreAllReverseRoutes) {
177
178
  try {
178
179
  app.get(
179
180
  `/:${camelcase(primaryKey)}/${routePathName}`,
@@ -300,7 +301,7 @@ export async function entityPlugin (app, opts) {
300
301
  return ignoreRoute.path === targetOpenapiPath && ignoreRoute.method === 'GET'
301
302
  })
302
303
 
303
- if (!ignoredReversedGETRoute) {
304
+ if (!ignoredReversedGETRoute && !ignoreAllReverseRoutes) {
304
305
  try {
305
306
  app.get(
306
307
  `/:${camelcase(primaryKey)}/${targetRelation}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/sql-openapi",
3
- "version": "3.41.0",
3
+ "version": "3.43.0",
4
4
  "description": "Map a SQL database to OpenAPI, for Fastify",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "typescript": "^5.5.4",
27
27
  "why-is-node-running": "^2.2.2",
28
28
  "yaml": "^2.4.1",
29
- "@platformatic/sql-mapper": "3.41.0"
29
+ "@platformatic/sql-mapper": "3.43.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "@fastify/deepmerge": "^2.0.0",
@@ -36,9 +36,9 @@
36
36
  "camelcase": "^6.3.0",
37
37
  "fastify-plugin": "^5.0.0",
38
38
  "inflected": "^2.1.0",
39
- "@platformatic/foundation": "3.41.0",
40
- "@platformatic/scalar-theme": "3.41.0",
41
- "@platformatic/sql-json-schema-mapper": "3.41.0"
39
+ "@platformatic/foundation": "3.43.0",
40
+ "@platformatic/scalar-theme": "3.43.0",
41
+ "@platformatic/sql-json-schema-mapper": "3.43.0"
42
42
  },
43
43
  "tsd": {
44
44
  "directory": "test/types"