Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding contentEncoding and contentMediaType to 3.1 #126

Merged
merged 4 commits into from
Dec 20, 2023

Conversation

RobinTail
Copy link
Contributor

@RobinTail RobinTail commented Dec 19, 2023

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
Copy link
Contributor Author

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 RobinTail marked this pull request as ready for review December 19, 2023 08:55
test/package.json Outdated Show resolved Hide resolved
@RobinTail
Copy link
Contributor Author

@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 RobinTail changed the title Adding contentEncoding and contentMediaType Adding contentEncoding and contentMediaType to 3.1 Dec 19, 2023
Copy link
Contributor

@pjmolina pjmolina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your changes, makes sense to me @RobinTail.

Two comments/questions before merging:

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?

test/package.json Outdated Show resolved Hide resolved
@RobinTail
Copy link
Contributor Author

Sure, @pjmolina , I can improve it accordingly.

@RobinTail
Copy link
Contributor Author

RobinTail commented Dec 19, 2023

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 .

  • ts-node removed from the test environment;
  • Running tsx in CJS mode is ensured by the cts file extension;
  • tsx moved to devDependencies.

@pjmolina pjmolina merged commit 9ab6d8b into metadevpro:master Dec 20, 2023
2 checks passed
@pjmolina
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants