metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.
MIT License
485 stars 64 forks source link

Adding `contentEncoding` and `contentMediaType` to 3.1 #126

Closed RobinTail closed 10 months ago

RobinTail commented 10 months ago

Adding two new fields to the SchemaObject of 3.1. The contentEncoding is supposed to override the format (such as binary) for the case of file transfer. The contentMediaType is optional when defined as a key of ContentObject but it's JSON Schema compliant.

First appearance in 3.1.0 RC0: https://github.com/OAI/OpenAPI-Specification/releases/tag/3.1.0-rc0

Documentation: https://swagger.io/specification/?#considerations-for-file-uploads

RobinTail commented 10 months ago

The CI fails to run

> openapi3-ts-test@1.0.0 test:ts-esm
> ts-node --esm --project fixture/tsconfig.node.json index.ts

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /home/runner/work/openapi3-ts/openapi3-ts/test/index.ts
    at new NodeError (node:internal/errors:405:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:136:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:182:36)
    at defaultLoad (node:internal/modules/esm/load:101:20)
    at nextLoad (node:internal/modules/esm/hooks:864:28)
    at load (/home/runner/work/openapi3-ts/openapi3-ts/test/node_modules/ts-node/dist/child/child-loader.js:19:122)
    at nextLoad (node:internal/modules/esm/hooks:864:28)
    at Hooks.load (node:internal/modules/esm/hooks:447:26)
    at MessagePort.handleMessage (node:internal/modules/esm/worker:196:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:786:20) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'

Consider switching to tsx

RobinTail commented 10 months ago

@pjmolina , please review. I tried to collect as much information about those fields as possible into the JSDOC. However, the PR is open for your edits.

RobinTail commented 10 months ago

Sure, @pjmolina , I can improve it accordingly.

RobinTail commented 10 months ago

Can we replace in full ts-node to use tsx? Just to avoid having 2 dependencies for the same task. Can you move these tools from the dependencies to dev-dependencies block as they are not needed for distribution?

All done, @pjmolina .

pjmolina commented 10 months ago

Thanks @RobinTail Published in v. 4.2.0 https://www.npmjs.com/package/openapi3-ts?activeTab=versions