Skip to content

Commit 6b0734c

Browse files
docs: add contentType to openapi-generator README
1 parent 5ef252c commit 6b0734c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/openapi-generator/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,38 @@ const SampleSchema = t.type({
468468

469469
These are some tags that you can use in your schema JSDocs are custom to this generator.
470470

471+
- `@contentType` allows you to override the default `application/json` content type for
472+
requests and responses. Can be applied at route level (affects both request and
473+
response), request body level, or individual response status code level.
471474
- `@private` allows you to mark any field as in any schema as private. The final spec
472475
will have `x-internal: true` for schemas with the `@private` tag.
473476
- `@deprecated` allows to mark any field in any schema as deprecated. The final spec
474477
will include `deprecated: true` in the final specificaiton.
475478

476479
```typescript
477480
import * as t from 'io-ts';
481+
import * as h from '@api-ts/io-ts-http';
482+
483+
/**
484+
* Route-level content type
485+
* @contentType multipart/form-data
486+
*/
487+
export const uploadRoute = h.httpRoute({
488+
request: h.httpRequest({
489+
/**
490+
* Request-specific content type
491+
* @contentType application/xml
492+
*/
493+
body: t.type({ data: t.string }),
494+
}),
495+
response: {
496+
/**
497+
* Response-specific content type
498+
* @contentType text/plain
499+
*/
500+
200: t.string,
501+
},
502+
});
478503

479504
const Schema = t.type({
480505
/** @private */

0 commit comments

Comments
 (0)