Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values supporting scalar and object #4423

Merged
merged 15 commits into from
Sep 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/openapi3/test/primitive-types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ describe("openapi3: primitives", () => {
expect(res.schemas.Pet.properties.name.default).toEqual("Shorty");
});

it("known scalar used as a default value", async () => {
const res = await oapiForModel(
"Test",
`
model Test { minDate: utcDateTime = utcDateTime.fromISO("2024-01-2T3:04:05Z"); }
`
);

expect(res.schemas.Test.properties.minDate.default).toEqual("2024-01-2T3:04:05Z");
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
expect(res.schemas.Test.properties.minDate.format).toEqual("date-time");
expect(res.schemas.Test.properties.minDate.type).toEqual("string");
AlitzelMendez marked this conversation as resolved.
Show resolved Hide resolved
});

it("object value used as a default value", async () => {
const res = await oapiForModel(
"Test",
Expand Down
Loading