-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin for schema validation #407
base: beckn-onix-v1.0-develop
Are you sure you want to change the base?
Plugin for schema validation #407
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Comments
…ugin, and deleted schema_die path from config
parts := strings.Split(relativePath, string(os.PathSeparator)) | ||
|
||
// Ensure that the file path has at least 3 parts: domain, version, and schema file. | ||
if len(parts) < 3 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add more robust validation to handle edge cases, such as empty paths or incorrect directory structures.
start := time.Now() | ||
|
||
var memStatsBefore runtime.MemStats | ||
runtime.ReadMemStats(&memStatsBefore) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this to a debug mode or removing it entirely, not needed in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review all your test cases, add descriptions, make sure it is clear on what is expected outcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test case for payloads with missing or extra fields?
// indexed by their schema filenames. | ||
func (vp *TekuriValidatorProvider) Initialize(schemaDir string) (map[string]plugins.Validator, error) { | ||
// Initialize the SchemaCache map to store the compiled schemas using a unique key (domain/version/schema). | ||
vp.SchemaCache = make(map[string]*jsonschema.Schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initialize the SchemaCache in the constructor or ensure it is only initialized once.
Created a plugin that validates a payload against a predefined schema to ensure data integrity. Additionally, I developed a small API that handles POST requests, utilizing this plugin to validate the incoming data before processing it further.