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

Using Reference in OpenAPI-Spec to file in the same directory does not work as expected #20

Open
LoeFe opened this issue Nov 16, 2022 · 1 comment

Comments

@LoeFe
Copy link

LoeFe commented Nov 16, 2022

The openapi-typescript-validator works very well for single-file openapi-specs. Thanks for the cool tool! 👍

But: When I split the openapi-spec into multiple files as described in the openapi 3.0 spec with "$ref: my2ndFile.yaml" I receive an ENOENT error. This is becasue the generator is searching in the cwd of the node-process, which is "project_root/validator" and not relatively to the interface-file, that I hand over to generate-function of the openapi-typescript-validator.

As far as I understood the code, the root cause is, "DEFAULT_OPTIONS.cwd" of json-schema-to-typescript package is pointing to process.cwd(). It could have been overwritten when calling compile, but options are not set.

const compiledTypescriptModels = await compile(

The file structure in my project is as follows:

├── project_root
│ ├── validator
│ │ ├── generator.js
│ ├── openApiSpec
│ │ ├── interface.yaml
│ │ ├── my2ndFile.yaml

@LoeFe
Copy link
Author

LoeFe commented Nov 16, 2022

This issue seems to be closely related to #11

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

1 participant