-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
If you have a swagger with a $ref to a URL that returns a redirect status code (e.g. an HTTP URL that returns a 301 to the HTTPS version of the URL), the parser won't follow the redirection and will fail.
The relevant stack trace looks like this:
java.lang.RuntimeException: Could not find parameters/x-correlator in contents of http://docs.baikalplatform.com/common/v2.0/common.json
at io.swagger.parser.ResolverCache.loadRef(ResolverCache.java:135)
at io.swagger.parser.processors.ParameterProcessor.processParameters(ParameterProcessor.java:37)
at io.swagger.parser.processors.OperationProcessor.processOperation(OperationProcessor.java:26)
at io.swagger.parser.processors.PathsProcessor.processPaths(PathsProcessor.java:101)
at io.swagger.parser.SwaggerResolver.resolve(SwaggerResolver.java:50)
at io.swagger.parser.SwaggerParser.parse(SwaggerParser.java:133)
at io.swagger.parser.SwaggerParser.parse(SwaggerParser.java:125)
and here's the result of curling the URL:
$ curl -i http://docs.baikalplatform.com/common/v2.0/common.json
HTTP/1.1 301 Moved Permanently
Server: CloudFront
Date: Thu, 20 Sep 2018 09:28:44 GMT
Content-Type: text/html
Content-Length: 183
Connection: keep-alive
Location: https://docs.baikalplatform.com/common/v2.0/common.json
X-Cache: Redirect from cloudfront
Via: 1.1 eab5fb7c81224eaac4ecc1cd39b0e964.cloudfront.net (CloudFront)
X-Amz-Cf-Id: ut8ivSDWn6asSuGogbHFF66027-H8OAGB0nQovVCOWhJ2Hxo5XLRiA==
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>CloudFront</center>
</body>
</html>
and the corresponding curl of the redirected URL, just so you can see that the parameter is in fact defined:
$ curl -i https://docs.baikalplatform.com/common/v2.0/common.json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 2102
Connection: keep-alive
Date: Thu, 16 Aug 2018 08:33:42 GMT
Last-Modified: Tue, 07 Aug 2018 09:19:34 GMT
ETag: "04cfec120c51ac4255c9968fa77efeb2"
Cache-Control: no-cache
Accept-Ranges: bytes
Server: AmazonS3
X-Cache: RefreshHit from cloudfront
Via: 1.1 4e4e9cc1cf6e6d6f48bc627cf1467aa9.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 3w-kc4TPCQ351V7m6i2eBwcHAw9jrSFghgVRZNOxQtZqByRowms0Bw==
{"info":{"description":"Common data for 4th Platform APIs","version":"2.0.0","title":"Common data for 4th Platform APIs","termsOfService":"https://www.telefonica.es/es/","contact":{"name":"4th Platform Team","email":"4pf@tid.es"}},"definitions":{"MoneyAmount":{"type":"object","description":"Money amount","required":["value","currency"],"properties":{"value":{"type":"number","format":"float","multipleOf":0.01,"description":"Amount value"},"currency":{"type":"string","description":"Currency code in which the amount is expressed. ISO 4217"},"tax_included":{"type":"boolean","description":"true if the amount includes government taxes","default":"false"}}},"Address":{"type":"object","description":"User's address information","required":["formatted"],"properties":{"formatted":{"type":"string","description":"Full address, formatted for display"},"street_address":{"type":"string","description":"Address information"},"postal_code":{"type":"string","description":"Postal code associated to the address"},"locality":{"type":"string","description":"City or locality where the user lives"},"country":{"type":"string","description":"Country name. Format iso3166-1"}}},"IdDocument":{"type":"object","description":"User legal id document information","required":["country","type","value"],"properties":{"country":{"type":"string","description":"Country of issuance of the id_document. Format iso3166-1"},"type":{"type":"string","description":"Type of document (e.g. passport)"},"value":{"type":"string","description":"Id number associated to the id_document"}}}},"parameters":{"x-correlator":{"in":"header","name":"x-correlator","type":"string","required":false,"description":"Correlation id for the different services"},"ID":{"in":"path","name":"id","type":"string","required":true,"description":"Resource identifier"},"Page":{"name":"page","in":"query","description":"Requested page number for pagination purpose","required":true,"type":"integer","format":"int32"},"PerPage":{"name":"per_page","in":"query","description":"Number of element per page","required":true,"type":"integer","format":"int32"}}}
Metadata
Metadata
Assignees
Labels
No labels