changes in Initialse method as adding AddResource function
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -84,10 +85,10 @@ func (v *tekuriValidator) Validate(ctx context.Context, data []byte) error {
|
||||
// }
|
||||
|
||||
// (Approach 2)(all json files for each schema from sub directories)
|
||||
|
||||
func (vp *tekuriValidatorProvider) Initialize(schemaDir string) (map[string]plugins.Validator, error) {
|
||||
vp.schemaCache = make(map[string]map[string]*jsonschema.Schema)
|
||||
validatorCache := make(map[string]plugins.Validator)
|
||||
baseCustomID := "https://core/v1.1.0/"
|
||||
|
||||
// Walk through the directory and compile all .json files
|
||||
err := filepath.Walk(schemaDir, func(path string, info os.FileInfo, err error) error {
|
||||
@@ -96,12 +97,28 @@ func (vp *tekuriValidatorProvider) Initialize(schemaDir string) (map[string]plug
|
||||
}
|
||||
if !info.IsDir() && filepath.Ext(info.Name()) == ".json" {
|
||||
filePath := filepath.Join(schemaDir, info.Name())
|
||||
fmt.Println("printing path : ", path)
|
||||
fmt.Println("Compiling file path: ", filePath)
|
||||
|
||||
// Construct the CustomID using baseCustomID and the file name
|
||||
customID := baseCustomID + info.Name()
|
||||
compiler := jsonschema.NewCompiler()
|
||||
|
||||
compiledSchema, err := compiler.Compile(path)
|
||||
resource, err := os.Open(path)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open JSON schema file %s: %v", info.Name(), err)
|
||||
}
|
||||
defer func() {
|
||||
if err := resource.Close(); err != nil {
|
||||
log.Printf("Error closing resource: %v", err)
|
||||
}
|
||||
}()
|
||||
// defer resource.Close()
|
||||
|
||||
if err := compiler.AddResource(customID, resource); err != nil {
|
||||
return fmt.Errorf("failed to add resource for JSON schema file %s and custom id is %s: %v", info.Name(), customID, err)
|
||||
}
|
||||
|
||||
// compiledSchema, err := compiler.Compile(path)
|
||||
compiledSchema, err := compiler.Compile(customID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to compile JSON schema from file %s: %v", info.Name(), err)
|
||||
}
|
||||
@@ -109,8 +126,6 @@ func (vp *tekuriValidatorProvider) Initialize(schemaDir string) (map[string]plug
|
||||
return fmt.Errorf("compiled schema is nil for file %s", info.Name())
|
||||
}
|
||||
|
||||
fmt.Printf("Compiled schema for file %s: %+v\n", info.Name(), compiledSchema)
|
||||
|
||||
dir := filepath.Base(filepath.Dir(filePath))
|
||||
if vp.schemaCache[dir] == nil {
|
||||
vp.schemaCache[dir] = make(map[string]*jsonschema.Schema)
|
||||
@@ -131,6 +146,7 @@ var _ plugins.ValidatorProvider = (*tekuriValidatorProvider)(nil)
|
||||
|
||||
var providerInstance = &tekuriValidatorProvider{}
|
||||
|
||||
// GetProvider returns the ValidatorProvider instance.
|
||||
func GetProvider() plugins.ValidatorProvider {
|
||||
return providerInstance
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type Message struct{}
|
||||
|
||||
func TestInitializeValidDirectory(t *testing.T) {
|
||||
provider := &tekuriValidatorProvider{}
|
||||
schemaDir := "../schema/ondc_trv10_2.0.0/"
|
||||
schemaDir := "../schema_valid/ondc_trv10_2.0.0/"
|
||||
_, err := provider.Initialize(schemaDir)
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
@@ -30,7 +30,7 @@ func TestInitializeValidDirectory(t *testing.T) {
|
||||
|
||||
func TestInitializeInValidDirectory(t *testing.T) {
|
||||
provider := &tekuriValidatorProvider{}
|
||||
schemaDir := "../schemas/ondc_trv10_2.0.0/"
|
||||
schemaDir := "../schema/ondc_trv10_2.0.0/"
|
||||
_, err := provider.Initialize(schemaDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read schema directory: %v", err)
|
||||
@@ -68,7 +68,7 @@ func TestInvalidCompileSchema(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateData(t *testing.T) {
|
||||
schemaDir := "../schema/ondc_trv10_2.0.0/"
|
||||
schemaDir := "../schema_valid/ondc_trv10_2.0.0/"
|
||||
if _, err := os.Stat(schemaDir); os.IsNotExist(err) {
|
||||
t.Fatalf("Schema directory does not exist: %v", schemaDir)
|
||||
}
|
||||
@@ -108,7 +108,7 @@ func TestValidateData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInValidateData(t *testing.T) {
|
||||
schemaDir := "../schema/ondc_trv10_2.0.0/"
|
||||
schemaDir := "../schema_valid/ondc_trv10_2.0.0/"
|
||||
|
||||
if _, err := os.Stat(schemaDir); os.IsNotExist(err) {
|
||||
t.Fatalf("Schema directory does not exist: %v", schemaDir)
|
||||
@@ -138,7 +138,7 @@ func TestInValidateData(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInValidateUnmarshalData(t *testing.T) {
|
||||
schemaDir := "../schema/ondc_trv10_2.0.0/"
|
||||
schemaDir := "../schema_valid/ondc_trv10_2.0.0/"
|
||||
|
||||
if _, err := os.Stat(schemaDir); os.IsNotExist(err) {
|
||||
t.Fatalf("Schema directory does not exist: %v", schemaDir)
|
||||
|
||||
Binary file not shown.
@@ -12,20 +12,24 @@ import (
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// PluginConfig represents the configuration for plugins, including the plugins themselves.
|
||||
type PluginConfig struct {
|
||||
Plugins Plugins `yaml:"plugins"`
|
||||
}
|
||||
|
||||
// Plugins holds the various plugin types used in the configuration.
|
||||
type Plugins struct {
|
||||
ValidationPlugin ValidationPlugin `yaml:"validation_plugin"`
|
||||
}
|
||||
|
||||
// ValidationPlugin represents a plugin with an ID, configuration, and the path to the plugin.
|
||||
type ValidationPlugin struct {
|
||||
ID string `yaml:"id"`
|
||||
Config PluginDetails `yaml:"config"`
|
||||
PluginPath string `yaml:"plugin_path"`
|
||||
}
|
||||
|
||||
// PluginDetails contains information about the plugin schema directory.
|
||||
type PluginDetails struct {
|
||||
Schema string `yaml:"schema_dir"`
|
||||
}
|
||||
@@ -87,7 +91,7 @@ func NewValidatorProvider(pluginsConfig PluginConfig) (*PluginManager, map[strin
|
||||
return &PluginManager{validatorProvider: validatorProvider}, validator, nil
|
||||
}
|
||||
|
||||
// loadPluginsConfig loads the plugins configuration from a YAML file.
|
||||
// LoadPluginsConfig loads the plugins configuration from a YAML file.
|
||||
func LoadPluginsConfig(filePath string) (PluginConfig, error) {
|
||||
// start := time.Now()
|
||||
|
||||
|
||||
@@ -22,8 +22,25 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"message": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"order_id": {
|
||||
"$ref": "definitions.json#/$defs/Order"
|
||||
},
|
||||
"cancellation_reason_id": {
|
||||
"$ref": "definitions.json#/$defs/Option"
|
||||
},
|
||||
"descriptor": {
|
||||
"$ref": "definitions.json#/$defs/Descriptor"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"order_id"
|
||||
]
|
||||
}
|
||||
|
||||
},
|
||||
"required": [
|
||||
"message",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/confirm",
|
||||
"$id": "confirm",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/init",
|
||||
"$id": "init",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnCancel",
|
||||
"$id": "OnCancel",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnConfirm",
|
||||
"$id": "OnConfirm",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnInit",
|
||||
"$id": "OnInit",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnRating",
|
||||
"$id": "OnRating",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnSearch",
|
||||
"$id": "OnSearch",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnSelect",
|
||||
"$id": "OnSelect",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnStatus",
|
||||
"$id": "OnStatus",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnSupport",
|
||||
"$id": "OnSupport",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnTrack",
|
||||
"$id": "OnTrack",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/OnUpdate",
|
||||
"$id": "OnUpdate",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/rating",
|
||||
"$id": "rating",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/Response",
|
||||
"$id": "Response",
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": []
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/status",
|
||||
"$id": "status",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/support",
|
||||
"$id": "support",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/track",
|
||||
"$id": "track",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/update",
|
||||
"$id": "update",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_cancel",
|
||||
"$id": "on_cancel",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_confirm",
|
||||
"$id": "on_confirm",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_init",
|
||||
"$id": "on_init",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_rating",
|
||||
"$id": "on_rating",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_search",
|
||||
"$id": "on_search",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_select",
|
||||
"$id": "on_select",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_status",
|
||||
"$id": "on_status",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_support",
|
||||
"$id": "on_support",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_track",
|
||||
"$id": "on_track",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/on_update",
|
||||
"$id": "on_update",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/search",
|
||||
"$id": "search",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://beckn.org/schema/select",
|
||||
"$id": "select",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/cancel",
|
||||
"$id": "cancel",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/cancel.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/cancel#"
|
||||
"$ref": "../../core/v1.1.0/cancel.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "./init.json#/allOf/2"
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/confirm",
|
||||
"$id": "confirm",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "./init.json#/allOf/2"
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/init",
|
||||
"$id": "init",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{ "$ref": "../core/v1.1.0/init.json#" },
|
||||
{ "$ref": "https://beckn.org/schema/init#" },
|
||||
{ "$ref": "../../core/v1.1.0/init.json#" },
|
||||
{
|
||||
"allOf": [
|
||||
{ "$ref": "./search.json#/properties/context/allOf/0" },
|
||||
@@ -43,7 +42,7 @@
|
||||
}
|
||||
},
|
||||
{ "$ref": "./confirm.json#/allOf/4" },
|
||||
{ "$ref": "./on_select.json#/allOf/10" },
|
||||
{ "$ref": "./on_select.json#" },
|
||||
{
|
||||
"properties": {
|
||||
"message": {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_init",
|
||||
"$id": "on_init",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/on_init.json#"
|
||||
"$ref": "../../core/v1.1.0/on_init.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/on_init#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_rating",
|
||||
"$id": "on_rating",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_search",
|
||||
"$id": "on_search",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/on_search.json#"
|
||||
"$ref": "../../core/v1.1.0/on_search.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/on_search#"
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_select",
|
||||
"$id": "on_select",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/on_select.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/on_select#"
|
||||
"$ref": "../../core/v1.1.0/on_select.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "./init.json#/allOf/2"
|
||||
},
|
||||
{
|
||||
"$ref": "#/paths/~1on_init/post/requestBody/content/application~1json/schema/allOf/1/allOf/2"
|
||||
},
|
||||
{
|
||||
"$ref": "#/paths/~1on_init/post/requestBody/content/application~1json/schema/allOf/1/allOf/4"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"message": {
|
||||
@@ -793,9 +784,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"$ref": "#/paths/~1on_init/post/requestBody/content/application~1json/schema/allOf/1/allOf/6"
|
||||
},
|
||||
{
|
||||
"properties": {
|
||||
"message": {
|
||||
@@ -819,9 +807,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"$ref": "#/paths/~1on_init/post/requestBody/content/application~1json/schema/allOf/1/allOf/7"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_status",
|
||||
"$id": "on_status",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_support",
|
||||
"$id": "on_support",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/on_track",
|
||||
"$id": "on_track",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/confirm.json#"
|
||||
"$ref": "../../core/v1.1.0/confirm.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/confirm#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/rating",
|
||||
"$id": "rating",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/rating.json#"
|
||||
"$ref": "../../core/v1.1.0/rating.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/rating#"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/search",
|
||||
"$id": "search",
|
||||
"allOf": [
|
||||
{ "$ref": "../core/v1.1.0/search.json#" },
|
||||
{ "$ref": "https://beckn.org/schema/search#" }
|
||||
{ "$ref": "../core/v1.1.0/search.json#" }
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -40,11 +39,11 @@
|
||||
},
|
||||
"bap_id": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!https?://).*$"
|
||||
"pattern": "^(http|https).*"
|
||||
},
|
||||
"bpp_id": {
|
||||
"type": "string",
|
||||
"pattern": "^(?!https?://).*$"
|
||||
"pattern": "^(http|https).*"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/select",
|
||||
"$id": "select",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{ "$ref": "../core/v1.1.0/select.json#" },
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/status",
|
||||
"$id": "status",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/status.json#"
|
||||
"$ref": "../../core/v1.1.0/status.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/status#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/support",
|
||||
"$id": "support",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/support.json#"
|
||||
"$ref": "../../core/v1.1.0/support.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/support#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/track",
|
||||
"$id": "track",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/track.json#"
|
||||
"$ref": "../../core/v1.1.0/track.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/track#"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://ondc.org/trv10/2.0.0/update",
|
||||
"$id": "update",
|
||||
"type": "object",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "../core/v1.1.0/update.json#"
|
||||
"$ref": "../../core/v1.1.0/update.json#"
|
||||
},
|
||||
{
|
||||
"$ref": "https://beckn.org/schema/update#"
|
||||
|
||||
@@ -248,498 +248,6 @@
|
||||
"required": ["intent"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"select": {
|
||||
"$id": "select#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"domain": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"country": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": ["IND"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
},
|
||||
"required": ["city", "country"]
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"enum": ["search"]
|
||||
},
|
||||
"bap_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"bap_uri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"bpp_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"bpp_uri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"transaction_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"message_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string",
|
||||
"format": "duration"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"domain",
|
||||
"location",
|
||||
"action",
|
||||
"bap_id",
|
||||
"bap_uri",
|
||||
"transaction_id",
|
||||
"message_id",
|
||||
"timestamp",
|
||||
"ttl"
|
||||
]
|
||||
},
|
||||
"message": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"intent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fulfillment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"stops": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"gps": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["gps"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["START", "END"]
|
||||
}
|
||||
},
|
||||
"required": ["location", "type"]
|
||||
},
|
||||
"minItems": 2,
|
||||
"maxItems": 2
|
||||
}
|
||||
},
|
||||
"required": ["stops"]
|
||||
},
|
||||
"payment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"collected_by": {
|
||||
"type": "string",
|
||||
"enum": ["BPP", "BAP"]
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
"maxItems": 2,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": ["SETTLEMENT_TERMS", "BUYER_FINDER_FEES"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"properties": {
|
||||
"code": {
|
||||
"const": "SETTLEMENT_TERMS"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"SETTLEMENT_BASIS",
|
||||
"SETTLEMENT_WINDOW",
|
||||
"STATIC_TERMS",
|
||||
"SETTLEMENT_TYPE",
|
||||
"DELAY_INTEREST"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["descriptor", "value"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"properties": {
|
||||
"code": {
|
||||
"const": "BUYER_FINDER_FEES"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"enum": ["BUYER_FINDER_FEES_PERCENTAGE"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"pattern": "^-?\\d+(\\.\\d+)?$"
|
||||
}
|
||||
},
|
||||
"required": ["descriptor", "value"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["descriptor"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["collected_by", "tags"]
|
||||
}
|
||||
},
|
||||
"required": ["fulfillment", "payment"]
|
||||
}
|
||||
},
|
||||
"required": ["intent"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"on_init": {
|
||||
"$id": "on_init#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"context": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"domain": {
|
||||
"type": "string"
|
||||
},
|
||||
"location": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"country": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": ["IND"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
},
|
||||
"required": ["city", "country"]
|
||||
},
|
||||
"action": {
|
||||
"type": "string",
|
||||
"enum": ["search"]
|
||||
},
|
||||
"bap_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"bap_uri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"bpp_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"bpp_uri": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
},
|
||||
"transaction_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"message_id": {
|
||||
"type": "string",
|
||||
"format": "uuid"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"ttl": {
|
||||
"type": "string",
|
||||
"format": "duration"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"domain",
|
||||
"location",
|
||||
"action",
|
||||
"bap_id",
|
||||
"bap_uri",
|
||||
"transaction_id",
|
||||
"message_id",
|
||||
"timestamp",
|
||||
"ttl"
|
||||
]
|
||||
},
|
||||
"message": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"intent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fulfillment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"stops": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"gps": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["gps"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["START", "END"]
|
||||
}
|
||||
},
|
||||
"required": ["location", "type"]
|
||||
},
|
||||
"minItems": 2,
|
||||
"maxItems": 2
|
||||
}
|
||||
},
|
||||
"required": ["stops"]
|
||||
},
|
||||
"payment": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"collected_by": {
|
||||
"type": "string",
|
||||
"enum": ["BPP", "BAP"]
|
||||
},
|
||||
"tags": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
"maxItems": 2,
|
||||
"uniqueItems": true,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": ["SETTLEMENT_TERMS", "BUYER_FINDER_FEES"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
},
|
||||
"allOf": [
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"properties": {
|
||||
"code": {
|
||||
"const": "SETTLEMENT_TERMS"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"SETTLEMENT_BASIS",
|
||||
"SETTLEMENT_WINDOW",
|
||||
"STATIC_TERMS",
|
||||
"SETTLEMENT_TYPE",
|
||||
"DELAY_INTEREST"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["descriptor", "value"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"properties": {
|
||||
"code": {
|
||||
"const": "BUYER_FINDER_FEES"
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"list": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"descriptor": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"code": {
|
||||
"enum": ["BUYER_FINDER_FEES_PERCENTAGE"]
|
||||
}
|
||||
},
|
||||
"required": ["code"]
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"pattern": "^-?\\d+(\\.\\d+)?$"
|
||||
}
|
||||
},
|
||||
"required": ["descriptor", "value"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": ["descriptor"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["collected_by", "tags"]
|
||||
}
|
||||
},
|
||||
"required": ["fulfillment", "payment"]
|
||||
}
|
||||
},
|
||||
"required": ["intent"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user