Open dzikoysk opened 1 year ago
I just discovered the same. You can give an absolute path to This is most definitely a bug IMO, but I cannot afford to look into what causes it at the moment.typegen
instead of placing the spec in the node_modules
directory.
I had the problem during modularization of an multi purposes REST API
$ref is a powerful mechanism to connect to remote, local resources or even database, ... The ref problem is to identify the exact context local, remote, ...
The best solution is to:
openapi.yaml:
... components: schemas: GetService: $ref: './component.yaml#/components/schemas/GetService' ... paths: /service: $ref: './component.yaml#/components/pathitems/service' ...
component.yaml:
... components: schemas: GetService: ... pathitems: service:
Convert yaml to JSON using the defrrencing of all dependencies to get an openapi.json without $ref
openapi read api/openapi.yaml --format=json --dereference > ./dist/openapi.json
Convert JSON openapi.json to openapi.d.ts
npx openapicmd typegen dist/openapi.json > ./src/types/openapi.d.ts
An example is available on https://github.com/pcolot01/BlackmagicRestOpenApi
Best
Docs references that definition can be read from file located in project dir:
typegen ./openapi.yml > client.d.ts - generate a type definition file
Unfortunately, it's not the case 7.3.2:
I've replaced it with the following command and it works:
But it doesn't seems to be right. Am I missing something or it's just a bug?