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

support default return schemas in openapi codegen #4145

Closed
wants to merge 0 commits into from

Conversation

barp
Copy link

@barp barp commented Feb 2, 2024

According to https://swagger.io/docs/specification/describing-responses/#default this is a valid way to describe a possible response.

Copy link

codesandbox bot commented Feb 2, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

netlify bot commented Feb 2, 2024

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 7928634
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/65bdfdc8e677d2000849a0e9
😎 Deploy Preview https://deploy-preview-4145--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codesandbox-ci bot commented Feb 2, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 7928634:

Sandbox Source
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@barp barp changed the title support default return schemas in openapi support default return schemas in openapi codegen Feb 2, 2024
@phryneas
Copy link
Member

phryneas commented Feb 2, 2024

Could you please add a test that shows a schema with this and the resulting generated code?

@barp
Copy link
Author

barp commented Feb 2, 2024

I have added a test, but for some reason I can't run it locally. I get weird errors unrelated to test itself.

➤ YN0000:     Jest encountered an unexpected token
➤ YN0000:
➤ YN0000:     Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or wh
en Jest is not configured to support such syntax.
➤ YN0000:
➤ YN0000:     Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configurat
ion.
➤ YN0000:
➤ YN0000:     By default "node_modules" folder is ignored by transformers.
➤ YN0000:
➤ YN0000:     Here's what you can do:
➤ YN0000:      • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
➤ YN0000:      • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
➤ YN0000:      • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config
.
➤ YN0000:      • If you need a custom transformation specify a "transform" option in your config.
➤ YN0000:      • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" co
nfig option.
➤ YN0000:
➤ YN0000:     You'll find more details and examples of these config options in the docs:
➤ YN0000:     https://jestjs.io/docs/configuration
➤ YN0000:     For information about custom transformations, see:
➤ YN0000:     https://jestjs.io/docs/code-transformation
➤ YN0000:
➤ YN0000:     Details:

not sure I am doing wrong I just tried to do:

yarn install
yarn test

@EskiMojo14
Copy link
Collaborator

codegen tests are currently broken after updating node-fetch (which is now ESM only, it seems) - #4137 is an attempt to fix it long term by migrating to vitest but we might just need to revert the node-fetch update in the meantime

@EskiMojo14
Copy link
Collaborator

merged in #4151 to temporarily revert back to node-fetch v2, try now

@barp
Copy link
Author

barp commented Feb 3, 2024

I have fixed the tests.

This adds | void to some response types but also fixes some response types for apis that only had default response type (like User apis in petstore).

@barp
Copy link
Author

barp commented Feb 3, 2024

The extra void was removed, it was a bug in the filter that removes all "void" from possible types.

@barp
Copy link
Author

barp commented Feb 3, 2024

Accidently closed this, reopened in #4152

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

3 participants