You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ A Prisma generator that automatically creates OpenAPI specifications from your P
25
25
-[Custom Configuration](#custom-configuration)
26
26
-[JSDoc Integration](#jsdoc-integration)
27
27
-[Prisma Comments as Descriptions](#prisma-comments-as-descriptions)
28
+
-[Field Exclusion](#field-exclusion)
28
29
-[Configuration](#configuration)
29
30
-[License](#license)
30
31
@@ -281,6 +282,38 @@ User:
281
282
description: Optional display name
282
283
```
283
284
285
+
### Field Exclusion
286
+
287
+
You can exclude specific fields from the generated OpenAPI schema using two approaches:
288
+
289
+
**1. Using `@openapi.ignore` in field comments:**
290
+
291
+
Add `@openapi.ignore` to a field's triple-slash comment to exclude it from the generated schema:
292
+
293
+
```prisma
294
+
model User {
295
+
id Int @id @default(autoincrement())
296
+
email String @unique
297
+
name String?
298
+
/// @openapi.ignore
299
+
password String
300
+
}
301
+
```
302
+
303
+
**2. Using `excludeFields` in generator config:**
304
+
305
+
Specify fields to exclude using `ModelName.fieldName` format:
306
+
307
+
```prisma
308
+
generator openapi {
309
+
provider = "prisma-openapi"
310
+
output = "./openapi"
311
+
excludeFields = "User.password, User.secretKey"
312
+
}
313
+
```
314
+
315
+
Both approaches can be used together. A field is excluded if it matches **either** condition. Excluded fields are removed from both `properties` and `required` in the generated schema.
316
+
284
317
## Configuration
285
318
286
319
| Option | Description | Default |
@@ -290,6 +323,7 @@ User:
290
323
| `description` | API description in OpenAPI spec | Empty string |
291
324
| `includeModels` | Comma-separated list of models to include | All models |
292
325
| `excludeModels` | Comma-separated list of models to exclude | None |
326
+
| `excludeFields` | Comma-separated list of fields to exclude (`ModelName.fieldName`) | None |
293
327
| `generateYaml` | Generate YAML format | `true` |
294
328
| `generateJson` | Generate JSON format | `false` |
295
329
| `generateJsDoc` | Include JSDoc comments in the schema | `false` |
0 commit comments