Closed richp10 closed 7 years ago
This error is not an error of parsing or libs, it is a validation error. The http scheme is empty .
Maybe you have call the validation in php-cli mode... In this case, you need to set the $_SERVER["REQUEST_SCHEME"] to simulate the http call.
You can find the code who read this env var in the context class : https://github.com/nabbar/SwaggerValidator-PHP/blob/master/src/Common/Context.php#L182 :
/**
* Load the called URL/Path to identify component
* like scheme, host, base path
*/
public function loadUri()
{
$this->contextScheme = $this->getEnv('REQUEST_SCHEME');
$this->contextHost = $this->getEnv('SERVER_NAME');
$uri = explode('?', $this->getEnv('REQUEST_URI'));
$this->contextBasePath = array_shift($uri);
}
Or, (and it could be a good idea) you can override the context/contextBase classes'methods and start the validation with you customized context classes.
You have some interface in this folder to help you in the custmization : https://github.com/nabbar/SwaggerValidator-PHP/tree/master/src/Interfaces
Ps : the scheme is the http, https in any url.
I complete my comments to explain this error logs :
[2017-04-25 13:50:56] : date time in old ISO form
[VALIDATE] : operation of validation a request or a response
[KO] : validation is in error (a parameter, body, header, url... validation could be wrong)
[{SwaggerValidator\Object\Swagger::checkSchemes#245] : origin of the error (Namespace, class, method and line)
- Scheme requested is not allowed : error message
... : the rest is a context usefull data extraction
In pretty print :
{
"contextMode":"DENY", => validation is run as deny mode, 2 options : DENY (stop with exception on any error find) or PASS (clean all bad data and continue validation)
"contextType":"REQUEST", => type of validation : Request or Response
"contextLocation":null, => the location elements (header, body, form, ...)
"contextScheme":false, => the scheme find (http, https, ...)
"contextHost":false, => the host extracted from the called url
"contextBasePath":"", => the api base path find in the called url
"contextRequestPath":null, => the request path find in the called url
"contextRoutePath":null, => the route path selected following the request path, scheme, basepath, parameters, …
"contextMethod":"get", => the method use in the http request
"contextDataPath":["#","schemes"], => this array represent all keys of the swagger schema from the beginning “#” to the current location
"contextDataCheck":[], => current data check (example size, type, format, …)
"contextDataValue":false, => the value currently validated
"contextDataExists":true, => precise if the data is find (like an isset or array_key_exists) : in swagger require do not means is not empty
"contextDataEmpty":true, => precise if the data is empty or not : : in swagger require do not means is not empty
"contextDecodeError":null, => error when decoded object (xml / json)
"contextDataType":null, => type of data (string, int32, int64, …)
"contextOther":[], => other data that could helps in understanding the error
"contextExternalRef":[], => list of all external ref used in the validation process
"contextIsCombined":null, => precise if the current validation is using anyOf, allOf or one of process
"contextValidationCode":null, => precise the error validation code when validating params/body
"mockedData":[] => this array help for mocking call in unit test for having the data sending to simulate query
}
Thanks for the other fix - my swagger.json now loads without error.
I now run:
And get error:
This is using the same swagger.json I sent you ..
Thanks!