Comments (16)
For now only options provided by the cli. I'm using Angular 17.3, I don't have tested until now the access to db.
from openapi-ts.
Hi @mrlubos , thank you for the fast response.
I have created a openapi-ts.config.js
and located at same level of package.json. I run on Windows 11.
The file content is :
/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').Config} */
export default {
input: 'http://localhost:5005/openapi.json',
output: 'web/src/generated/client',
exportSchemas:true
}
The script command to start on package.json
is :
"gen:api-create-services": "npx @nicolas-chaulet/openapi-typescript-codegen",
The error is :
> npm-run-all -l --sequential gen:*
[gen:api-create-services]
[gen:api-create-services] > [email protected] gen:api-create-services D:\_lab\src\frontend\xxxxxxxx-smartc-fe
[gen:api-create-services] > npx @nicolas-chaulet/openapi-typescript-codegen
[gen:api-create-services]
[gen:api-create-services] Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
[gen:api-create-services] at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:239:11)
[gen:api-create-services] at defaultLoad (node:internal/modules/esm/load:130:3)
[gen:api-create-services] at ModuleLoader.load (node:internal/modules/esm/loader:409:13)
[gen:api-create-services] at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:56)
[gen:api-create-services] at new ModuleJob (node:internal/modules/esm/module_job:65:26)
[gen:api-create-services] at #createModuleJob (node:internal/modules/esm/loader:303:17)
[gen:api-create-services] at ModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:260:34)
[gen:api-create-services] at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:241:17)
[gen:api-create-services] at async ModuleLoader.import (node:internal/modules/esm/loader:328:23) {
[gen:api-create-services] code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
[gen:api-create-services] }
[gen:api-create-services] ELIFECYCLE Command failed with exit code 1.
ERROR: "gen:api-create-services" exited with 1.
from openapi-ts.
@tajnymag you're on Windows, right? Are you able to check which part of the code is causing issues?
I'll be on my PC in a few hours, but I think I found the culprit.
To reliably load a local module, Nodejs expects file:// url protocol. By reading the source, I've found this function, which imports the config file without constructing a proper URL.
https://github.com/nicolas-chaulet/openapi-typescript-codegen/blob/master/src%2Findex.ts#L79
from openapi-ts.
I still trying now. One moment, I will inform you.
from openapi-ts.
It work !
But it is required this code :
/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
module.exports = {
input: 'http://localhost:5003/documentation/json',
output: 'web/src/generated/client',
exportSchemas: true,
}
Thank you all @mrlubos @tajnymag @nicolas-chaulet
from openapi-ts.
Hey @clabnet, this is something I was actually considering earlier today. Are you looking to put many settings inside that file? Is it a style preference?
P.S. Which Angular version are you using? Is everything working as expected?
from openapi-ts.
Hey @clabnet, you can now use a configuration file. Here's how it would look for you
/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').Config} */
export default {
exportSchemas: true,
input: 'http://localhost:5005/openapi.json',
output: 'src/generated/client',
}
Note that you do not need to supply client
anymore, it will be automatically detected 🎉
Let me know if this works for you!
P.S. You need to be using Node.js v18 or newer
from openapi-ts.
@clabnet which Node version are you on?
from openapi-ts.
@mrlubos * 20.11.0 (Currently using 64-bit executable)
from openapi-ts.
@tajnymag you're on Windows, right? Are you able to check which part of the code is causing issues?
from openapi-ts.
@clabnet do you mind trying with v0.27.32
? (note that I renamed Config
type to UserConfig
, though that doesn't affect the runtime)
@tajnymag thanks for your help!
from openapi-ts.
@clabnet is this working for you now?
from openapi-ts.
Unfortunately the version "@nicolas-chaulet/openapi-typescript-codegen": "^0.27.35",
don't work on my windows 11 machine
openapi-ts.config.ts
/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
export default {
input: 'http://localhost:5003/documentation/json',
output: 'web/src/generated/client',
exportSchemas: true,
}
package.json
scripts: {
...
"gen:api-create-services": "npx @nicolas-chaulet/openapi-typescript-codegen",
....
}
Error :
PS D:\LABS\src\frontend\exiway-smartc-fe> pnpm generate:all
> @schneider/[email protected] generate:all D:\LABS\src\frontend\my-smartc-fe
> npm-run-all -l --sequential gen:*
[gen:api-create-services]
[gen:api-create-services] > @xxxxx/[email protected] gen:api-create-services D:\LABS\src\frontend\my-smartc-fe
[gen:api-create-services] > npx @nicolas-chaulet/openapi-typescript-codegen
[gen:api-create-services]
[gen:api-create-services] Error: 🚫 input not provided - provide path to OpenAPI specification
[gen:api-create-services] at To (file:///D:/LABS/src/frontend/my-smartc-fe/node_modules/.pnpm/@[email protected]/node_modules/@nicolas-chaulet/openapi-typescript-codegen/dist/node/index.js:1:229289)
[gen:api-create-services] at async Eo (file:///D:/LABS/src/frontend/my-smartc-fe/node_modules/.pnpm/@[email protected]/node_modules/@nicolas-chaulet/openapi-typescript-codegen/dist/node/index.js:1:229642)
[gen:api-create-services] at async start (file:///D:/LABS/src/frontend/my-smartc-fe/node_modules/.pnpm/@[email protected]/node_modules/@nicolas-chaulet/openapi-typescript-codegen/bin/index.js:45:9)
[gen:api-create-services] ELIFECYCLE Command failed with exit code 1.
ERROR: "gen:api-create-services" exited with 1.
A partial of openapi.json
{"openapi":"3.0.3","info":{"title":"REST API","description":"Exposing a SQL database as REST","version":"1.0.0"},"components":{"schemas":{"Drawing":{"title":"Drawing","description":"A Drawing","type":"object","properties":{"filename":{"type":"string","nullable":true},"extension":{"type":"string","nullable":true},"size":{"type":"integer","nullable":true},"item":{"type":"string","nullable":true},"creationDate":{"type":"string","nullable":true},"lastAccessDate":{"type":"string","nullable":true},"lastModifiedDate":{"type":"string","nullable":true},"plantId":{"type":"string","nullable":true},"tag":{"type":"string","nullable":true},"uuid":{"type":"string","nullable":true}},"additionalProperties":false},"DrawingInput":{"title":"DrawingInput","description":"A Drawing","type":"object","properties":{"filename":{"type":"string"},"extension":{"type":"string"},"size":{"type":"integer"},"item":{"type":"string","nullable":true},"creationDate":{"type":"string"},"lastAccessDate":{"type":"string"},"lastModifiedDate":{"type":"string"},"plantId":{"type":"string"},"tag":{"type":"string","nullable":true},"uuid":{"type":"string"}},"additionalProperties":false,"required":["creationDate","extension","filename","lastAccessDate","lastModifiedDate","plantId","size"]},"Bom":{"title":"Bom","description":"A Bom","type":"object","properties":{"item":{"type":"string","nullable":true},"path":{"type":"string","nullable":true},"pathId":{"type":"string","nullable":true},"level":{"type":"integer","nullable":true},"parent":{"type":"string","nullable":true},"type":{"type":"string","nullable":true},"id":{"type":"integer","nullable":true},"selection":{"type":"string","nullable":true},"tN":{"type":"integer","nullable":true},"quantity":{"type":"integer","nullable":true},"r
from openapi-ts.
@clabnet try with openapi-ts.config.js
instead of openapi-ts.config.ts
please, we don't support .ts
just yet #84
from openapi-ts.
@clabnet Did you have any luck with the config file?
from openapi-ts.
Great @clabnet! FYI I'm working on making exportSchemas true by default, so you shouldn't need that option soon either!
from openapi-ts.
Related Issues (20)
- It does not pickup typescript in monorepo environment w/ pnpm HOT 3
- Content type headers not passed onto request HOT 4
- Rename conflicting TypeScript identifiers
- DeprecationWarning: fs.Stats constructor is deprecated HOT 3
- export eslint.rules for external usage HOT 3
- Got client HOT 15
- Non-global clients/configs HOT 6
- Export services as module instead of class to enable tree shaking. HOT 10
- Unused @ts-expect-error comment HOT 5
- Support for exactOptionalPropertyTypes in tsconfig.json HOT 2
- Validate response against openapi schema HOT 1
- Standalone package for your client HOT 1
- [question] How does this package compare to `openapi-typescript`? HOT 2
- can't generate a node16 moduleResolution compatible package HOT 8
- Improve support for `Accept` and `Content-Type` headers
- Newly exported `DefaultService` does not exist HOT 14
- Export `FetchClient` interface
- Parameters with `in: header` cause incompatible types HOT 3
- fetch client: snake_case path arguments get converted to camelCase in types, but not in template string HOT 3
- Error types no longer strongly typed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-ts.