@get-enlace/express 0.0.3 → 0.0.4

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.
Files changed (2) hide show
  1. package/README.md +27 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -22,6 +22,33 @@ app.use('/enlace', enlace({ spec: './openapi.json' }));
22
22
  `spec` is a file path, a URL, or an already-parsed OpenAPI 3.x object — whatever's easiest to
23
23
  point at your API's own document.
24
24
 
25
+ ## Using an existing spec setup
26
+
27
+ Already generating your OpenAPI document with [`swagger-jsdoc`](https://www.npmjs.com/package/swagger-jsdoc)?
28
+ Call it yourself and pass the result straight through as `spec` — no separate export step:
29
+
30
+ ```ts
31
+ import express from 'express';
32
+ import swaggerJsdoc from 'swagger-jsdoc';
33
+ import { enlace } from '@get-enlace/express';
34
+
35
+ const spec = swaggerJsdoc({
36
+ definition: {
37
+ openapi: '3.0.3',
38
+ info: { title: 'My API', version: '1.0.0' },
39
+ servers: [{ url: 'http://localhost:4000' }], // Enlace sends requests here
40
+ },
41
+ apis: ['./routes/*.js'],
42
+ });
43
+
44
+ app.use('/enlace', enlace({ spec }));
45
+ ```
46
+
47
+ `swaggerJsdoc()` runs synchronously with no server instance required, so this works before
48
+ `app.listen()`. Already mounting `swagger-ui-express` from the same document? Handing that same
49
+ object to `enlace()` too doesn't change how that keeps working — they're independent consumers of
50
+ the same spec.
51
+
25
52
  ## Learn more
26
53
 
27
54
  See the [`enlace-js` repo](https://github.com/get-enlace/enlace-js) for the other adapters in
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@get-enlace/express",
3
3
  "private": false,
4
- "version": "0.0.3",
4
+ "version": "0.0.4",
5
5
  "description": "Simple Express adapter for @get-enlace/ui. Early dev preview: no persistence yet (serves the spec + UI bundle only), install via the `dev` dist-tag on GitHub Packages.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,7 +33,7 @@
33
33
  "express": "^4.17.0 || ^5.0.0"
34
34
  },
35
35
  "dependencies": {
36
- "@get-enlace/ui": "0.0.3",
36
+ "@get-enlace/ui": "0.0.4",
37
37
  "js-yaml": "^4.1.0"
38
38
  },
39
39
  "devDependencies": {