Skip to content

Commit

Permalink
Fix: schema.json route
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKoerner committed Jul 15, 2023
1 parent 87c93bb commit bf225f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/src/actions/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const paramsSchema = (options: JSONSchema7): JSONSchema7 => {
},
format: {
type: 'string',
enum: ['svg', 'png', 'jpg', 'json'],
enum: ['svg', 'png', 'jpg', 'json', 'schema.json'],
},
options: restOptions,
},
Expand Down Expand Up @@ -81,7 +81,13 @@ const plugin: FastifyPluginCallback<Options> = async (
},
},
async (request, reply) => {
const format: 'svg' | 'png' | 'jpg' | 'json' = request.params.format ?? 'svg';
const format = request.params.format ?? 'svg';

if (format === 'schema.json') {
reply.header('Content-Type', 'application/json');

return JSON.stringify(queryStringSchema, undefined, 2);
}

let options: any = request.params.options || request.query;

Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type CollectionType = Record<
>;

export type AvatarRouteParams = {
format?: 'svg' | 'png' | 'jpg' | 'json';
format?: 'svg' | 'png' | 'jpg' | 'json' | 'schema.json';
seed?: string;
options?: unknown;
};
Expand Down

0 comments on commit bf225f0

Please sign in to comment.