Skip to content

Can't make types readonly via NodeJS API #425

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

Closed
craigmiller160 opened this issue Oct 20, 2022 · 2 comments
Closed

Can't make types readonly via NodeJS API #425

craigmiller160 opened this issue Oct 20, 2022 · 2 comments

Comments

@craigmiller160
Copy link

const { generateApi } = require('swagger-typescript-api');
const path = require('path');
generateApi({
	name: 'my-app',
	output: path.join(process.cwd(), 'src', 'types', 'generated'),
	url: 'https://127.0.0.1:8080/v3/api-docs',
	prettier: true,
	generateClient: false,
	sortTypes: true
})
	.then(() => console.log('API types successfully generated'))
	.catch((ex) => console.error('Error generating API types', ex));

This all works just fine, except it outputs non-read-only types. From the docs I've seen, the only way to get readonly types is via the CLI. This seems like a strange limitation of the NodeJS API. Is there something I'm missing? Or is there just no way to make the generated types readonly?

@js2me
Copy link
Member

js2me commented Oct 21, 2022

Hi @craigmiller160 , try to add property addReadonly: true
I'll update typesccript declaration file for this field

@js2me js2me mentioned this issue Oct 21, 2022
@js2me
Copy link
Member

js2me commented Oct 22, 2022

@craigmiller160 thanks for this issue!
Should be fixed in 10.0.3

@js2me js2me closed this as completed Oct 22, 2022
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

No branches or pull requests

2 participants