APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.09k stars 154 forks source link

Package openapi-types is missing, but gets requested by yarn #199

Open Myrmod opened 2 years ago

Myrmod commented 2 years ago

I created a monorepository using turborepo with the yarn (v3.1.1) option. In there I have two express applications that use swagger. While trying to install I get the following log output:

YN0000: ┌ Resolution step
➤ YN0002: │ swagger-parser@npm:10.0.2 doesn't provide openapi-types (p8111f), requested by @apidevtools/swagger-parser
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 0s 389ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ turbo@npm:1.0.28 must be built because it never has been before or the last one failed
➤ YN0009: │ turbo@npm:1.0.28 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-9144f05e/build.log)
➤ YN0000: └ Completed in 0s 310ms
➤ YN0000: Failed with errors in 0s 889ms
yarn explain peer-requirements p8111f
➤ YN0000: swagger-parser@npm:10.0.2 doesn't provide openapi-types, breaking the following requirements:

➤ YN0000: @apidevtools/swagger-parser@npm:10.0.2 [9cdba] → >=7 ✘

What might be the reason and how can I debug this properly?

Myrmod commented 2 years ago

A workaround I could use is this:

yarn remove swagger-jsdoc && yarn add -P swagger-jsdoc

Here we also install the peer dependencies.

sinoohe commented 2 years ago

I have the same problem. but not with yarn, with npm

node_modules/@apidevtools/swagger-parser/lib/index.d.ts:1:25 - error TS2307: Cannot find module 'openapi-types' or its corresponding type declarations.

1 import { OpenAPI } from "openapi-types";
philsturgeon commented 2 years ago

@sinoohe could you help me out with a pull request here? I've spent three days straight just trying to fix the upstream dependencies to get 10.1.0 out and I really need a hand with this.

dividedmind commented 2 years ago

I think the problem is that swagger-parser shim package needs to declare the openapi-types as (some kind of) a dependency.

AlbinoGeek commented 2 years ago

+1 -- Basically, this project requires 7 but the current is 12.

This should be a peerDependency.

philsturgeon commented 2 years ago

Anyone got a PR to fix this.

meronogbai commented 7 months ago

You can install openapi-types to your project to get around this.