Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"multi-semantic-release": "3.0.2",
"patch-package": "8.0.0",
"pre-commit": "1.2.2",
"prettier": "2.8.8",
"prettier": "3.0.3",
"turbo": "1.10.13",
"typescript": "4.6.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/express-wrapper/test/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const GetHelloWorld = async (params: { id: string }) =>
({
type: 'ok',
payload: params,
} as const);
}) as const;

test('should offer a delightful developer experience', async () => {
const app = createServer(ApiSpec, (app: express.Application) => {
Expand Down
51 changes: 30 additions & 21 deletions packages/openapi-generator/src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ function schemaToOpenAPI(
case 'object':
return {
type: 'object',
properties: Object.entries(schema.properties).reduce((acc, [name, prop]) => {
const innerSchema = schemaToOpenAPI(prop);
if (innerSchema === undefined) {
return acc;
}
properties: Object.entries(schema.properties).reduce(
(acc, [name, prop]) => {
const innerSchema = schemaToOpenAPI(prop);
if (innerSchema === undefined) {
return acc;
}

return { ...acc, [name]: innerSchema };
}, {} as Record<string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject>),
return { ...acc, [name]: innerSchema };
},
{} as Record<string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject>,
),
required: schema.required,
};
case 'intersection':
Expand Down Expand Up @@ -127,21 +130,27 @@ export function convertRoutesToOpenAPI(
routes: Route[],
schemas: Components,
): OpenAPIV3_1.Document {
const paths = routes.reduce((acc, route) => {
const [path, method, pathItem] = routeToOpenAPI(route);
let pathObject = acc[path] ?? {};
pathObject[method] = pathItem;
return { ...acc, [path]: pathObject };
}, {} as Record<string, Record<string, OpenAPIV3_1.PathItemObject>>);
const paths = routes.reduce(
(acc, route) => {
const [path, method, pathItem] = routeToOpenAPI(route);
let pathObject = acc[path] ?? {};
pathObject[method] = pathItem;
return { ...acc, [path]: pathObject };
},
{} as Record<string, Record<string, OpenAPIV3_1.PathItemObject>>,
);

const openapiSchemas = Object.entries(schemas).reduce((acc, [name, schema]) => {
const openapiSchema = schemaToOpenAPI(schema);
if (openapiSchema === undefined) {
return acc;
} else {
return { ...acc, [name]: openapiSchema };
}
}, {} as Record<string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject>);
const openapiSchemas = Object.entries(schemas).reduce(
(acc, [name, schema]) => {
const openapiSchema = schemaToOpenAPI(schema);
if (openapiSchema === undefined) {
return acc;
} else {
return { ...acc, [name]: openapiSchema };
}
},
{} as Record<string, OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject>,
);

return {
openapi: '3.1.0',
Expand Down