Skip to content

Commit

Permalink
Default content description
Browse files Browse the repository at this point in the history
  • Loading branch information
GDownes committed Oct 17, 2023
1 parent 7286eca commit 6a3c938
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ ${this.aws ? "import {APIGatewayProxyEvent, APIGatewayProxyResult} from 'aws-lam
${this.hydra ? "import {ResourceApiDefinition, CollectionApiDefinition, ScopedOperation} from '@hexlabs/lambda-api-ts';" : ""}
// eslint-disable-next-line @typescript-eslint/no-var-requires
import schema from './schema.json';
import * as Model from "./model.js";
import * as Model from "./model";
import {Validator} from '@hexlabs/schema-api-ts';
${this.aws ? `export interface Parts<Q extends Record<string, string>,MQ extends Record<string, string[]>,P extends Record<string, string>,H extends Record<string, string>,MH extends Record<string, string[]>> {
Expand Down
2 changes: 1 addition & 1 deletion src/schema-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class OpenApiSpecificationBuilder<S extends {components: {schemas?: any,
return {'application/text': {schema: SchemaBuilder.create().string(), example, examples, encoding}};
}

response(description: string, content: OASResponse['content'], headers: string[] = []): OASResponse {
response(content: OASResponse['content'], description = '', headers: string[] = []): OASResponse {
return {description, content, headers: headers.reduce((prev, name) => ({ ...prev, [name]: {required: true, schema: { type: 'string' }} }), {})}
}

Expand Down
10 changes: 5 additions & 5 deletions test/schema-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default OpenApiSpecificationBuilder
.create(schemas, { title: 'Chicken Store API', version: '1.0.0'})
.add('servers', () => servers)
.defaultResponses(o => ({
200: o.response('', o.textContent())
200: o.response(o.textContent())
}))
.addComponent('securitySchemes', o => ({ Auth: o.openIdConnectScheme('.well-known/xyz')}))
.add('paths', o => ({
Expand All @@ -45,7 +45,7 @@ export default OpenApiSpecificationBuilder
security: [{Auth: ['read', 'write', 'admin']}],
operationId: 'getChickens',
responses: {
200: o.response('The Flock', o.jsonContent('ChickenCollection')),
200: o.response(o.jsonContent('ChickenCollection'), 'The Flock'),
}
},
post: {
Expand All @@ -72,7 +72,7 @@ export default OpenApiSpecificationBuilder
o.query('someOtherQuery', false, true)
],
responses: {
200: {description: 'The Chicken', content: o.jsonContent('Chicken')},
200: {content: o.jsonContent('Chicken'), description: 'The Chicken'},
}
},
put: {
Expand All @@ -86,8 +86,8 @@ export default OpenApiSpecificationBuilder
content: o.jsonContent('ChickenCreateRequest')
},
responses: {
200: o.response('The Chicken', {...o.jsonContent('Chicken'), ...o.textContent()}),
404: o.response('Not Found', o.textContent()),
200: o.response({...o.jsonContent('Chicken'), ...o.textContent()}, 'The Chicken'),
404: o.response( o.textContent(), 'Not Found'),
}
},
delete: {
Expand Down

0 comments on commit 6a3c938

Please sign in to comment.