corrections
This commit is contained in:
parent
338d8defdb
commit
89f6717f0b
@ -125,9 +125,6 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetValidateError_En(ValidateErrorCode val
|
|||||||
switch (schemaErrorCode) {
|
switch (schemaErrorCode) {
|
||||||
case kSchemaErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
|
case kSchemaErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
|
||||||
|
|
||||||
case kSchemaErrorSpecUnknown: return RAPIDJSON_ERROR_STRING("JSON schema draft or OpenAPI version is not recognized.");
|
|
||||||
case kSchemaErrorSpecUnsupported: return RAPIDJSON_ERROR_STRING("JSON schema draft or OpenAPI version is not supported.");
|
|
||||||
case kSchemaErrorSpecIllegal: return RAPIDJSON_ERROR_STRING("Both JSON schema draft and OpenAPI version found in document.");
|
|
||||||
case kSchemaErrorStartUnknown: return RAPIDJSON_ERROR_STRING("Pointer '%value' to start of schema does not resolve to a location in the document.");
|
case kSchemaErrorStartUnknown: return RAPIDJSON_ERROR_STRING("Pointer '%value' to start of schema does not resolve to a location in the document.");
|
||||||
case kSchemaErrorRefPlainName: return RAPIDJSON_ERROR_STRING("$ref fragment '%value' must be a JSON pointer.");
|
case kSchemaErrorRefPlainName: return RAPIDJSON_ERROR_STRING("$ref fragment '%value' must be a JSON pointer.");
|
||||||
case kSchemaErrorRefInvalid: return RAPIDJSON_ERROR_STRING("$ref must not be an empty string.");
|
case kSchemaErrorRefInvalid: return RAPIDJSON_ERROR_STRING("$ref must not be an empty string.");
|
||||||
@ -136,7 +133,6 @@ inline const RAPIDJSON_ERROR_CHARTYPE* GetValidateError_En(ValidateErrorCode val
|
|||||||
case kSchemaErrorRefCyclical: return RAPIDJSON_ERROR_STRING("$ref '%value' is cyclical.");
|
case kSchemaErrorRefCyclical: return RAPIDJSON_ERROR_STRING("$ref '%value' is cyclical.");
|
||||||
case kSchemaErrorRefNoRemoteProvider: return RAPIDJSON_ERROR_STRING("$ref is remote but there is no remote provider.");
|
case kSchemaErrorRefNoRemoteProvider: return RAPIDJSON_ERROR_STRING("$ref is remote but there is no remote provider.");
|
||||||
case kSchemaErrorRefNoRemoteSchema: return RAPIDJSON_ERROR_STRING("$ref '%value' is remote but the remote provider did not return a schema.");
|
case kSchemaErrorRefNoRemoteSchema: return RAPIDJSON_ERROR_STRING("$ref '%value' is remote but the remote provider did not return a schema.");
|
||||||
case kSchemaErrorReadOnlyAndWriteOnly: return RAPIDJSON_ERROR_STRING("Property must not be both 'readOnly' and 'writeOnly'.");
|
|
||||||
case kSchemaErrorRegexInvalid: return RAPIDJSON_ERROR_STRING("Invalid regular expression '%value' in 'pattern' or 'patternProperties'.");
|
case kSchemaErrorRegexInvalid: return RAPIDJSON_ERROR_STRING("Invalid regular expression '%value' in 'pattern' or 'patternProperties'.");
|
||||||
|
|
||||||
default: return RAPIDJSON_ERROR_STRING("Unknown error.");
|
default: return RAPIDJSON_ERROR_STRING("Unknown error.");
|
||||||
|
@ -217,9 +217,6 @@ typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetValidateErrorFunc)(ValidateErrorCod
|
|||||||
enum SchemaErrorCode {
|
enum SchemaErrorCode {
|
||||||
kSchemaErrorNone = 0, //!< No error.
|
kSchemaErrorNone = 0, //!< No error.
|
||||||
|
|
||||||
kSchemaErrorSpecUnknown, //!< JSON schema draft or OpenAPI version is not recognized
|
|
||||||
kSchemaErrorSpecUnsupported, //!< JSON schema draft or OpenAPI version is not supported
|
|
||||||
kSchemaErrorSpecIllegal, //!< Both JSON schema draft and OpenAPI version found in document
|
|
||||||
kSchemaErrorStartUnknown, //!< Pointer to start of schema does not resolve to a location in the document
|
kSchemaErrorStartUnknown, //!< Pointer to start of schema does not resolve to a location in the document
|
||||||
kSchemaErrorRefPlainName, //!< $ref fragment must be a JSON pointer
|
kSchemaErrorRefPlainName, //!< $ref fragment must be a JSON pointer
|
||||||
kSchemaErrorRefInvalid, //!< $ref must not be an empty string
|
kSchemaErrorRefInvalid, //!< $ref must not be an empty string
|
||||||
@ -228,7 +225,6 @@ enum SchemaErrorCode {
|
|||||||
kSchemaErrorRefCyclical, //!< $ref is cyclical
|
kSchemaErrorRefCyclical, //!< $ref is cyclical
|
||||||
kSchemaErrorRefNoRemoteProvider, //!< $ref is remote but there is no remote provider
|
kSchemaErrorRefNoRemoteProvider, //!< $ref is remote but there is no remote provider
|
||||||
kSchemaErrorRefNoRemoteSchema, //!< $ref is remote but the remote provider did not return a schema
|
kSchemaErrorRefNoRemoteSchema, //!< $ref is remote but the remote provider did not return a schema
|
||||||
kSchemaErrorReadOnlyAndWriteOnly, //!< Property must not be both 'readOnly' and 'writeOnly'
|
|
||||||
kSchemaErrorRegexInvalid //!< Invalid regular expression in 'pattern' or 'patternProperties'
|
kSchemaErrorRegexInvalid //!< Invalid regular expression in 'pattern' or 'patternProperties'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2152,7 +2152,7 @@ public:
|
|||||||
|
|
||||||
virtual const SchemaDocumentType* GetRemoteDocument(const char* uri, SizeType length) {
|
virtual const SchemaDocumentType* GetRemoteDocument(const char* uri, SizeType length) {
|
||||||
for (size_t i = 0; i < kCount; i++)
|
for (size_t i = 0; i < kCount; i++)
|
||||||
if (typename SchemaDocumentType::SValue(uri, length) == sd_[i]->GetURI())
|
if (typename SchemaDocumentType::GValue(uri, length) == sd_[i]->GetURI())
|
||||||
return sd_[i];
|
return sd_[i];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2995,15 +2995,6 @@ TEST(SchemaValidator, Schema_StartUnknown) {
|
|||||||
SCHEMAERROR(s, "{\"StartUnknown\":{\"errorCode\":1,\"instanceRef\":\"#\", \"value\":\"#/nowhere\"}}");
|
SCHEMAERROR(s, "{\"StartUnknown\":{\"errorCode\":1,\"instanceRef\":\"#\", \"value\":\"#/nowhere\"}}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// $ref is a non-JSON pointer fragment - not allowed when OpenAPI
|
|
||||||
TEST(SchemaValidator, Schema_RefPlainNameOpenApi) {
|
|
||||||
typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
|
|
||||||
Document sd;
|
|
||||||
sd.Parse("{\"swagger\": \"2.0\", \"type\": \"object\", \"properties\": {\"myInt1\": {\"$ref\": \"#myId\"}, \"myStr\": {\"type\": \"string\", \"id\": \"#myStrId\"}, \"myInt2\": {\"type\": \"integer\", \"id\": \"#myId\"}}}");
|
|
||||||
SchemaDocumentType s(sd);
|
|
||||||
SCHEMAERROR(s, "{\"RefPlainName\":{\"errorCode\":2,\"instanceRef\":\"#/properties/myInt1\",\"value\":\"#myId\"}}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// $ref is a non-JSON pointer fragment - not allowed when remote document
|
// $ref is a non-JSON pointer fragment - not allowed when remote document
|
||||||
TEST(SchemaValidator, Schema_RefPlainNameRemote) {
|
TEST(SchemaValidator, Schema_RefPlainNameRemote) {
|
||||||
typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
|
typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user