Skip to content

Commit

Permalink
Fix parseDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Jul 12, 2024
1 parent cc872cc commit 3dc32db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/nextlove/src/generators/lib/zod-openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ function parseDescription(zodRef: OpenApiZodAny): SchemaObject {
if (!testFrontMatter(trimmedDescription))
return { description: zodRef.description }
const { attributes, body } = parseFrontMatter(trimmedDescription)
let output: SchemaObject = {}
const output: SchemaObject = {}
if (body.trim()) output.description = body.trim()
if (typeof attributes === "object" && attributes !== null) {
if ("deprecated" in attributes && attributes.deprecated) {
output.deprecated = true
}

output = prefixKeysWithX(output)
Object.entries(prefixKeysWithX(attributes)).forEach(([key, value]) => {
output[key] = value
})
}

return output
Expand Down

0 comments on commit 3dc32db

Please sign in to comment.