Skip to content

Commit

Permalink
fix: show readonly in openapi spec of model property if it is generated
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz authored and dhmlau committed Oct 3, 2024
1 parent 0bc6eba commit 2809bb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ describe('build-schema', () => {
});
});

it('show generated', () => {
expect(
metaToJsonProperty({
type: String,
description: 'test',
generated: true,
}),
).to.eql({
type: 'string',
description: 'test',
readOnly: true,
});
});

it('keeps AJV keywords', () => {
const schema = metaToJsonProperty({
type: String,
Expand Down
3 changes: 3 additions & 0 deletions packages/repository-json-schema/src/build-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export function metaToJsonProperty(meta: PropertyDefinition): JsonSchema {
} else {
result = propDef;
}
if (meta.generated) {
result.readOnly = true;
}

const wrappedType = stringTypeToWrapper(propertyType);
const resolvedType = resolveType(wrappedType);
Expand Down

0 comments on commit 2809bb2

Please sign in to comment.