networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
861 stars 325 forks source link

Error message is not showing exact element containing error #369

Closed nggoenka closed 6 months ago

nggoenka commented 3 years ago

Every invalid json element shows same error: $: should be valid to one and only one of the schemas.

stevehu commented 3 years ago

Could you please create a PR with your test case to reproduce your issue?

nggoenka commented 3 years ago

Please have a check https://github.com/nggoenka/FhirValidationExample/pull/1

nggoenka commented 3 years ago

ValidatorExample is giving below result: [$: should be valid to one and only one of the schemas ] it should point out exact element in json having issue.

Krishna-capone commented 3 years ago

@nggoenka This is the issue referenced and fixed in #366 . The fix has been merged and it should be available in the latest release. Thanks

nggoenka commented 3 years ago

I am getting below error while creating PR. remote: Permission to networknt/json-schema-validator.git denied to nggoenka. fatal: unable to access 'https://github.com/networknt/json-schema-validator.git/': The requested URL returned error: 403

stevehu commented 3 years ago

@nggoenka We have two-factor authentication enabled so HTTPS might not work. Try to switch to SSH when you clone the project if you have the write permission. If you fork the project, I don't know what is going on. It might be Github unavailable at the moment.

nggoenka commented 3 years ago

@Krishna-capone after new release.....Please find below expected error: $.identifier[0].use1: is not defined in the schema and the schema does not allow additional properties, instaed of it, I am getting below error: [$.gender: is not defined in the schema and the schema does not allow additional properties, $.active: is not defined in the schema and the schema does not allow additional properties, $.telecom: is not defined in the schema and the schema does not allow additional properties, $.birthDate: is not defined in the schema and the schema does not allow additional properties, $._birthDate: is not defined in the schema and the schema does not allow additional properties, $.identifier[0].use1: is not defined in the schema and the schema does not allow additional properties, $.name: array found, string expected, $.resourceType: must be a constant value Account, $.resourceType: must be a constant value ActivityDefinition, $.subject: is missing but it is required, $.name: is not defined in the schema and the schema does not allow additional properties, $.patient: is missing but it is required, $.participant: is missing but it is required, $.appointment: is missing but it is required, $.agent: is missing but it is required, $.source: is missing but it is required, $.type: is missing but it is required, $.identifier: is not defined in the schema and the schema does not allow additional properties, $.code: is missing but it is required, $.resourceType: must be a constant value Binary, $.resourceType: must be a constant value BiologicallyDerivedProduct, $.resourceType: must be a constant value Bundle, $.resourceType: must be a constant value CapabilityStatement, $.resourceType: must be a constant value CareTeam, $.referencedItem: is missing but it is required, $.resourceType: must be a constant value ChargeItemDefinition, $.insurance: is missing but it is required, $.provider: is missing but it is required, $.priority: is missing but it is required, $.insurer: is missing but it is required, $.resourceType: must be a constant value CodeSystem, $.resourceType: must be a constant value Communication, $.resourceType: must be a constant value CommunicationRequest, $.resourceType: must be a constant value CompartmentDefinition, $.author: is missing but it is required, $.resourceType: must be a constant value ConceptMap, $.scope: is missing but it is required, $.category: is missing but it is required, $.resourceType: must be a constant value Contract, $.payor: is missing but it is required, $.beneficiary: is missing but it is required, $.request: is missing but it is required, $.resourceType: must be a constant value DetectedIssue, $.resourceType: must be a constant value Device, $.resourceType: must be a constant value DeviceDefinition, $.device: is missing but it is required, $.content: is missing but it is required, $.exposureAlternative: is missing but it is required, $.exposure: is missing but it is required, $.outcome: is missing but it is required, $.population: is missing but it is required, $.class: is missing but it is required, $.payloadType: is missing but it is required, $.connectionType: is missing but it is required, $.resourceType: must be a constant value EnrollmentRequest, $.resourceType: must be a constant value EnrollmentResponse, $.trigger: is missing but it is required, $.exposureBackground: is missing but it is required, $.characteristic: is missing but it is required, $.resourceType: must be a constant value ExampleScenario, $.relationship: is missing but it is required, $.description: is missing but it is required, $.resourceType: must be a constant value GraphDefinition, $.resourceType: must be a constant value Group, $.resourceType: must be a constant value GuidanceResponse, $.resourceType: must be a constant value HealthcareService, $.vaccineCode: is missing but it is required, $.doseStatus: is missing but it is required, $.targetDisease: is missing but it is required, $.immunizationEvent: is missing but it is required, $.recommendation: is missing but it is required, $.resourceType: must be a constant value ImplementationGuide, $.resourceType: must be a constant value InsurancePlan, $.resourceType: must be a constant value Invoice, $.item: is missing but it is required, $.resourceType: must be a constant value List, $.resourceType: must be a constant value Location, $.resourceType: must be a constant value Measure, $.period: is missing but it is required, $.measure: is missing but it is required, $.resourceType: must be a constant value Medication, $.resourceType: must be a constant value MedicationDispense, $.resourceType: must be a constant value MedicationKnowledge, $.name[0].given: is not defined in the schema and the schema does not allow additional properties, $.name[0].use: is not defined in the schema and the schema does not allow additional properties, $.name[0].family: is not defined in the schema and the schema does not allow additional properties, $.name[1].given: is not defined in the schema and the schema does not allow additional properties, $.name[1].use: is not defined in the schema and the schema does not allow additional properties, $.name[2].given: is not defined in the schema and the schema does not allow additional properties, $.name[2].period: is not defined in the schema and the schema does not allow additional properties, $.name[2].use: is not defined in the schema and the schema does not allow additional properties, $.name[2].family: is not defined in the schema and the schema does not allow additional properties, $.resourceType: must be a constant value MedicinalProduct, $.resourceType: must be a constant value MedicinalProductAuthorization, $.resourceType: must be a constant value MedicinalProductContraindication, $.resourceType: must be a constant value MedicinalProductIndication, $.role: is missing but it is required, $.resourceType: must be a constant value MedicinalProductInteraction, $.quantity: is missing but it is required, $.manufacturedDoseForm: is missing but it is required, $.packageItem: is missing but it is required, $.administrableDoseForm: is missing but it is required, $.routeOfAdministration: is missing but it is required, $.resourceType: must be a constant value MedicinalProductUndesirableEffect, $.resourceType: must be a constant value MessageDefinition, $.resourceType: must be a constant value MolecularSequence, $.uniqueId: is missing but it is required, $.resourceType: must be a constant value OperationDefinition, $.issue: is missing but it is required, $.resourceType: must be a constant value Organization, $.resourceType: must be a constant value OrganizationAffiliation, $.resourceType: must be a constant value Parameters, $.amount: is missing but it is required, $.recipient: is missing but it is required, $.payment: is missing but it is required, $.paymentAmount: is missing but it is required, $.resourceType: must be a constant value Person, $.resourceType: must be a constant value PlanDefinition, $.resourceType: must be a constant value Practitioner, $.resourceType: must be a constant value PractitionerRole, $.target: is missing but it is required, $.resourceType: must be a constant value Questionnaire, $.resourceType: must be a constant value QuestionnaireResponse, $.resourceType: must be a constant value RequestGroup, $.resourceType: must be a constant value ResearchStudy, $.study: is missing but it is required, $.individual: is missing but it is required, $.actor: is missing but it is required, $.resourceType: must be a constant value SearchParameter, $.schedule: is missing but it is required, $.resourceType: must be a constant value Specimen, $.resourceType: must be a constant value SpecimenDefinition, $.resourceType: must be a constant value StructureDefinition, $.group: is missing but it is required, $.channel: is missing but it is required, $.resourceType: must be a constant value SubstanceNucleicAcid, $.resourceType: must be a constant value SubstancePolymer, $.resourceType: must be a constant value SubstanceProtein, $.resourceType: must be a constant value SubstanceReferenceInformation, $.resourceType: must be a constant value SubstanceSourceMaterial, $.resourceType: must be a constant value SubstanceSpecification, $.resourceType: must be a constant value SupplyDelivery, $.resourceType: must be a constant value Task, $.resourceType: must be a constant value TerminologyCapabilities, $.testScript: is missing but it is required, $.resourceType: must be a constant value TestScript, $.resourceType: must be a constant value ValueSet, $.resourceType: must be a constant value VerificationResult, $.prescriber: is missing but it is required, $.lensSpecification: is missing but it is required

nggoenka commented 3 years ago

@Krishna-capone after new release.....Please find below expected error: $.identifier[0].use1: is not defined in the schema and the schema does not allow additional properties, instaed of it, I am getting below error: [$.gender: is not defined in the schema and the schema does not allow additional properties, $.active: is not defined in the schema and the schema does not allow additional properties, $.telecom: is not defined in the schema and the schema does not allow additional properties, $.birthDate: is not defined in the schema and the schema does not allow additional properties, $._birthDate: is not defined in the schema and the schema does not allow additional properties, $.identifier[0].use1: is not defined in the schema and the schema does not allow additional properties, $.name: array found, string expected, $.resourceType: must be a constant value Account, $.resourceType: must be a constant value ActivityDefinition, $.subject: is missing but it is required, $.name: is not defined in the schema and the schema does not allow additional properties, $.patient: is missing but it is required, $.participant: is missing but it is required, $.appointment: is missing but it is required, $.agent: is missing but it is required, $.source: is missing but it is required, $.type: is missing but it is required, $.identifier: is not defined in the schema and the schema does not allow additional properties, $.code: is missing but it is required, $.resourceType: must be a constant value Binary, $.resourceType: must be a constant value BiologicallyDerivedProduct, $.resourceType: must be a constant value Bundle, $.resourceType: must be a constant value CapabilityStatement, $.resourceType: must be a constant value CareTeam, $.referencedItem: is missing but it is required, $.resourceType: must be a constant value ChargeItemDefinition, $.insurance: is missing but it is required, $.provider: is missing but it is required, $.priority: is missing but it is required, $.insurer: is missing but it is required, $.resourceType: must be a constant value CodeSystem, $.resourceType: must be a constant value Communication, $.resourceType: must be a constant value CommunicationRequest, $.resourceType: must be a constant value CompartmentDefinition, $.author: is missing but it is required, $.resourceType: must be a constant value ConceptMap, $.scope: is missing but it is required, $.category: is missing but it is required, $.resourceType: must be a constant value Contract, $.payor: is missing but it is required, $.beneficiary: is missing but it is required, $.request: is missing but it is required, $.resourceType: must be a constant value DetectedIssue, $.resourceType: must be a constant value Device, $.resourceType: must be a constant value DeviceDefinition, $.device: is missing but it is required, $.content: is missing but it is required, $.exposureAlternative: is missing but it is required, $.exposure: is missing but it is required, $.outcome: is missing but it is required, $.population: is missing but it is required, $.class: is missing but it is required, $.payloadType: is missing but it is required, $.connectionType: is missing but it is required, $.resourceType: must be a constant value EnrollmentRequest, $.resourceType: must be a constant value EnrollmentResponse, $.trigger: is missing but it is required, $.exposureBackground: is missing but it is required, $.characteristic: is missing but it is required, $.resourceType: must be a constant value ExampleScenario, $.relationship: is missing but it is required, $.description: is missing but it is required, $.resourceType: must be a constant value GraphDefinition, $.resourceType: must be a constant value Group, $.resourceType: must be a constant value GuidanceResponse, $.resourceType: must be a constant value HealthcareService, $.vaccineCode: is missing but it is required, $.doseStatus: is missing but it is required, $.targetDisease: is missing but it is required, $.immunizationEvent: is missing but it is required, $.recommendation: is missing but it is required, $.resourceType: must be a constant value ImplementationGuide, $.resourceType: must be a constant value InsurancePlan, $.resourceType: must be a constant value Invoice, $.item: is missing but it is required, $.resourceType: must be a constant value List, $.resourceType: must be a constant value Location, $.resourceType: must be a constant value Measure, $.period: is missing but it is required, $.measure: is missing but it is required, $.resourceType: must be a constant value Medication, $.resourceType: must be a constant value MedicationDispense, $.resourceType: must be a constant value MedicationKnowledge, $.name[0].given: is not defined in the schema and the schema does not allow additional properties, $.name[0].use: is not defined in the schema and the schema does not allow additional properties, $.name[0].family: is not defined in the schema and the schema does not allow additional properties, $.name[1].given: is not defined in the schema and the schema does not allow additional properties, $.name[1].use: is not defined in the schema and the schema does not allow additional properties, $.name[2].given: is not defined in the schema and the schema does not allow additional properties, $.name[2].period: is not defined in the schema and the schema does not allow additional properties, $.name[2].use: is not defined in the schema and the schema does not allow additional properties, $.name[2].family: is not defined in the schema and the schema does not allow additional properties, $.resourceType: must be a constant value MedicinalProduct, $.resourceType: must be a constant value MedicinalProductAuthorization, $.resourceType: must be a constant value MedicinalProductContraindication, $.resourceType: must be a constant value MedicinalProductIndication, $.role: is missing but it is required, $.resourceType: must be a constant value MedicinalProductInteraction, $.quantity: is missing but it is required, $.manufacturedDoseForm: is missing but it is required, $.packageItem: is missing but it is required, $.administrableDoseForm: is missing but it is required, $.routeOfAdministration: is missing but it is required, $.resourceType: must be a constant value MedicinalProductUndesirableEffect, $.resourceType: must be a constant value MessageDefinition, $.resourceType: must be a constant value MolecularSequence, $.uniqueId: is missing but it is required, $.resourceType: must be a constant value OperationDefinition, $.issue: is missing but it is required, $.resourceType: must be a constant value Organization, $.resourceType: must be a constant value OrganizationAffiliation, $.resourceType: must be a constant value Parameters, $.amount: is missing but it is required, $.recipient: is missing but it is required, $.payment: is missing but it is required, $.paymentAmount: is missing but it is required, $.resourceType: must be a constant value Person, $.resourceType: must be a constant value PlanDefinition, $.resourceType: must be a constant value Practitioner, $.resourceType: must be a constant value PractitionerRole, $.target: is missing but it is required, $.resourceType: must be a constant value Questionnaire, $.resourceType: must be a constant value QuestionnaireResponse, $.resourceType: must be a constant value RequestGroup, $.resourceType: must be a constant value ResearchStudy, $.study: is missing but it is required, $.individual: is missing but it is required, $.actor: is missing but it is required, $.resourceType: must be a constant value SearchParameter, $.schedule: is missing but it is required, $.resourceType: must be a constant value Specimen, $.resourceType: must be a constant value SpecimenDefinition, $.resourceType: must be a constant value StructureDefinition, $.group: is missing but it is required, $.channel: is missing but it is required, $.resourceType: must be a constant value SubstanceNucleicAcid, $.resourceType: must be a constant value SubstancePolymer, $.resourceType: must be a constant value SubstanceProtein, $.resourceType: must be a constant value SubstanceReferenceInformation, $.resourceType: must be a constant value SubstanceSourceMaterial, $.resourceType: must be a constant value SubstanceSpecification, $.resourceType: must be a constant value SupplyDelivery, $.resourceType: must be a constant value Task, $.resourceType: must be a constant value TerminologyCapabilities, $.testScript: is missing but it is required, $.resourceType: must be a constant value TestScript, $.resourceType: must be a constant value ValueSet, $.resourceType: must be a constant value VerificationResult, $.prescriber: is missing but it is required, $.lensSpecification: is missing but it is required

Please find sample code to test here: https://github.com/nggoenka/FhirValidationExample/pull/1

Krishna-capone commented 3 years ago

@nggoenka , My fix is for Oneof Validator. In your schema i did not find any one of validation configured. So the error is not related to one of validation.

stevehu commented 6 months ago

@nggoenka Have you had a chance to try the latest version? Let's open a new issue if the issue is not resolved. Thanks.