beckn / protocol-server

protocol-server
19 stars 38 forks source link

Add ability to use domain specific yaml for validation #111

Closed vbabuEM closed 2 months ago

vbabuEM commented 2 months ago

Description

Currently the protocol server uses core yaml (core_0.9.4.yaml and core_1.1.0.yaml) for request validation. The script to use depends on the version string in the context. Extend this facility to use a combination of version and domain tag. Requirements:

  1. A new optional configuration value needs to be added called useDomainSpecificYAML. The default value should be false. If this configuration value is not there in default.yaml, even then it should be considered as false.
  2. If the value of useDomainSpecificYAML is false, the system will use the current logic of choosing the yaml file based on the version in the context
  3. If the value of useDomainSpecificYAML is true, the system will create a filename of form $context_$version.yaml and try to load that for validation. If that file does not exist, then it uses the current logic of using only the version.

Test cases:

  1. Do not have the key useDomainSpecificYAML in default.yaml. The protocol server should pick up core_0.9.4.yaml or core_1.1.0.yaml for validation.
  2. Have the key useDomainSpecificYAML in default.yaml and give it a value false. The protocol server should pick up core_0.9.4.yaml or core_1.1.0.yaml for validation.
  3. Have the key useDomainSpecificYAML in default.yaml and give it a value true. Do not add any domain specific file. The protocol server should pick up core_0.9.4.yaml or core_1.1.0.yaml for validation.
  4. Have the key useDomainSpecificYAML in default.yaml and give it a value true. Have a domain specific file. Now send a request in the same domain and version. The new file should be picked up for validation.
shreyvishal commented 2 months ago

Current Status: Done with the development part raised the PR for review.

PRs: PR for Master PR for Develop cc: @vishi24 @vbabuEM

shreyvishal commented 2 months ago

Current Status: Code is approved and merged cc: @vishi24