Skip to content

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

@LoeFe

Description

@LoeFe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions