question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

swagger2openapi: connection issues when using http2

See original GitHub issue

Detailed Description

When I try to run swagger2openapi on one of our online definitions I get the following error:

internal/http2/util.js:476
      throw new ERR_HTTP2_INVALID_CONNECTION_HEADERS(key);
      ^

TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]: HTTP/1 Connection specific headers are forbidden: "connection"
    at mapToHeaders (internal/http2/util.js:476:13)
    at ClientHttp2Session.request (internal/http2/core.js:1480:25)
    at HttpRequestManager.makeHttp2Request (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:413:30)
    at HttpRequestManager.makeRequest (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:344:21)
    at HttpRequestManager.onIdentification (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:279:24)
    at HttpRequestManager.onIdentify (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:379:9)
    at TLSSocket.onConnect (/Users/p.deraaij/projects/api-testing/node_modules/http2-client/lib/request.js:450:9)
    at Object.onceWrapper (events.js:276:13)
    at TLSSocket.emit (events.js:188:13)
    at TLSSocket.onConnectSecure (_tls_wrap.js:1167:10)

I’ve traced it down to a difference between node-fetch-h2 and http2-client.

http2-client removes the connection header while creating a HTTP2 request. However, node-fetch-h2 adds a Connection header, note the capital C. As a result the HTTP2 request is made with a Connection header which is invalid.

The reason node-fetch-h2 adds a Connection header is due to two reasons:

  1. There is no connection header already
  2. No agent is defined on the request.

If s2o is used by oas-resolver it does define an agent and therefore doesn’t throw this issue. Swagger2openapi doesn’t do that by default.

So, either this should be fixed by one of the two dependencies or swagger2open should by default use an agent. The latter option feels valid, but curious to other opinions.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pderaaijcommented, Feb 11, 2019

Well, even with a light mocking server you can test a connection cycle. Any regression on header/connection level + response headers will be found.

0reactions
MikeRalphsoncommented, Feb 11, 2019

Successfully published:

  • oas-linter@3.0.1
  • oas-resolver@2.2.1
  • oas-validator@3.2.1
  • reftools@1.0.7
  • swagger2openapi@5.2.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger2/Open API Swagger UI support request #105 - GitHub
Original issue description. I am interested in having Swagger2 support for Swagger UI with Sam local running Lambda SpringBoot.
Read more >
swagger2openapi - npm
swagger2openapi will automatically 'repair' a number of problems where non-compliant Swagger 2.0 schemas have been used. It will attempt to ...
Read more >
OpenAPI Specification - Version 2.0 - Swagger
Version 2.0 specification defines a set of files required to describe an API. These files can then be used by the Swagger-UI project...
Read more >
Why does my Swagger UI try to access non http content when ...
When deployed to AWS with a HTTPS ALB, I see it trying to load some HTTP content; which of course get blocked by...
Read more >
A Visual Guide to What's New in Swagger 3.0
Here's a hoverable overview of the structure of Swagger 2/OpenAPI 3 ... section with all references, you would now access something like ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found