Skip to content

Commit

Permalink
fix(includers/openapi): display req/res schema type
Browse files Browse the repository at this point in the history
display schema type of the requests and responses
  • Loading branch information
moki committed Jan 21, 2023
1 parent c436e31 commit 111dc02
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/services/includers/batteries/openapi/generators/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,19 @@ function openapiBody(allRefs: Refs, pagePrintedRefs: Set<string>, obj?: Schema)
if (!obj) {
return '';
}
const schema = obj.schema;

const {type = 'schema', schema} = obj;
const {content, tableRefs} = tableFromSchema(allRefs, schema);
const parsedSchema = prepareSampleObject(schema);

const result = [
block([
title(3)('Body'),
schemaCut('Sample', prepareSampleObject(schema)),
cut(code(stringify(parsedSchema, null, 4)), type),
content,
]),
];

while (tableRefs.length > 0) {
const tableRef = tableRefs.shift();
if (tableRef && !pagePrintedRefs.has(tableRef)) {
Expand All @@ -121,6 +124,7 @@ function openapiBody(allRefs: Refs, pagePrintedRefs: Set<string>, obj?: Schema)
pagePrintedRefs.add(tableRef);
}
}

return block(result);
}

Expand All @@ -139,10 +143,6 @@ function response(allRefs: Refs, visited: Set<string>, resp: Response) {
]);
}

export function schemaCut(heading: string, schema: any) {
return cut(code(stringify(schema, null, 4)), heading);
}

export {endpoint};

export default {endpoint};

0 comments on commit 111dc02

Please sign in to comment.