-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…t-for-zod-describe #94 Added support for `zod`'s `.describe` method
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { z } from 'zod'; | ||
import { expectSchema, registerSchema } from '../lib/helpers'; | ||
|
||
describe('describe', () => { | ||
it('generates OpenAPI schema with description when the .describe method is used', () => { | ||
const schema = registerSchema( | ||
'SimpleString', | ||
z.string().describe('This is a test string') | ||
); | ||
|
||
expectSchema([schema], { | ||
SimpleString: { type: 'string', description: 'This is a test string' }, | ||
}); | ||
}); | ||
|
||
it('can overload .openapi description when the .describe method is used', () => { | ||
const schema = registerSchema( | ||
'SimpleString', | ||
z | ||
.string() | ||
.openapi({ description: 'Alternative description' }) | ||
.describe('This is a test string') | ||
); | ||
|
||
expectSchema([schema], { | ||
SimpleString: { type: 'string', description: 'This is a test string' }, | ||
}); | ||
}); | ||
|
||
it('can overload descriptions from .describe with .openapi', () => { | ||
const schema = registerSchema( | ||
'SimpleString', | ||
z | ||
.string() | ||
.describe('This is a test string') | ||
.openapi({ description: 'Alternative description' }) | ||
); | ||
|
||
expectSchema([schema], { | ||
SimpleString: { type: 'string', description: 'Alternative description' }, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters