Skip to content

Folder as output doesn't work #925

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
AzazelloB opened this issue Jul 26, 2022 · 3 comments · Fixed by #999
Closed

Folder as output doesn't work #925

AzazelloB opened this issue Jul 26, 2022 · 3 comments · Fixed by #999
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project PRs welcome PRs are welcome to solve this issue! question Further information is requested

Comments

@AzazelloB
Copy link

AzazelloB commented Jul 26, 2022

This command npx openapi-typescript src/api/v1.0/schemas/**/*.json --output src/api/v1.0/types/ throws an error "src/api/v1.0/types/src/api/v1.0/schemas/schema.ts". Because in openapi-typescript/bin/cli.js:120 filename is not actually a filename.

Possible fix:
replace: const filename = pathToSpec.replace(new RegExp(`${path.extname(pathToSpec)}$`), ".ts");
to: const filename = path.basename(pathToSpec.replace(new RegExp(`${path.extname(pathToSpec)}$`), ".ts"));

@drwpow drwpow added the bug Something isn't working label Aug 6, 2022
@drwpow
Copy link
Contributor

drwpow commented Aug 6, 2022

I think there is a bug here, but I’m having a little trouble understanding how to reproduce it. Could you list out the contents of all your .json files so I could recreate?

@drwpow drwpow added question Further information is requested PRs welcome PRs are welcome to solve this issue! good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project labels Aug 6, 2022
@AzazelloB
Copy link
Author

Cannot reproduce this issue myself anymore. Don't know what was it. The only inconvenience now that in a folder structure like that

├── src
│   ├── api
│   │   ├── v1.0
│   │   │   ├── schemas
│   │   │   │   ├── file1.json
│   │   │   │   ├── file2.json
│   │   │   ├── types

it creates .ts file with full folder path in the name

├── src
│   ├── api
│   │   ├── v1.0
│   │   │   ├── schemas
│   │   │   │   ├── file1.json
│   │   │   │   ├── file2.json
│   │   │   ├── types
│   │   │    │  ├── src
│   │   │    │  │   ├── api
│   │   │    │  │   │   ├── v1.0
│   │   │    │  │   │   │   ├── schemas
│   │   │    │  │   │   │   │   ├── file1.ts
│   │   │    │  │   │   │   │   ├── file2.ts

Which is inconvenience but expected

@BTMPL
Copy link
Contributor

BTMPL commented Nov 19, 2022

Was anyone able to sidestep this issue? Downgrading to 5.x solves the problem, but I'd like to use the native fetch helper, which was added in 6.x

I'm still facing the issue with 6.0.3. It additionally tries to create a ... weird folder structure.

Working on Windows but the same happens with WSL2. Command I'm using is:

openapi-typescript src/contracts/**/openapi.yaml --output ./src/generated/api/
// ...
Error: ENOENT: no such file or directory, open 'F:\(...)\src\generated\api\src\contracts\depositAccountService\openapi.ts'

in (src/contracts):

├───customerService
│   │   openapi.yaml
│   │
│   └───schemas
│       ├───generic
│       │       errors.yaml
│       │       genericTypes.yaml
│       │
│       ├───request
│       │       requests.yaml
│       │
│       └───response
│               responses.yaml
│
└───depositAccountService
    │   openapi.yaml
    │
    └───schemas
            account-status-enum.yaml
            account.yaml
            customer-account.yaml
            problems.yaml
            saving-account.yaml
            saving-pot-status-enum.yaml
            saving-pot.yaml

out (src/generated/api)

└───src
    └───contracts
        └───customerService
            │   openapi.ts
            │
            ├───openapi.yaml
            └───src
                └───contracts
                    └───depositAccountService
                        └───openapi.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Straightforward problem, solvable for first-time contributors without deep knowledge of the project PRs welcome PRs are welcome to solve this issue! question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants