Skip to content

Conversation

cchenggit
Copy link
Collaborator

@cchenggit cchenggit commented Sep 15, 2025

issue #227

@cchenggit cchenggit marked this pull request as draft September 15, 2025 13:44
@cchenggit cchenggit force-pushed the feat/plugin-jsonschema-validator branch from e24260e to e613d87 Compare September 15, 2025 13:54
Copy link

codecov bot commented Sep 15, 2025

Codecov Report

❌ Patch coverage is 80.11696% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
plugins/jsonschema_validator/plugin.go 76.27% 20 Missing and 8 partials ⚠️
...gins/jsonschema_validator/jsonschema/jsonschema.go 84.21% 2 Missing and 1 partial ⚠️
utils/validate.go 86.95% 2 Missing and 1 partial ⚠️
Flag Coverage Δ
integration 76.91% <80.11%> (+0.27%) ⬆️
unit 11.65% <11.11%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
plugins/plugins.go 100.00% <100.00%> (ø)
proxy/gateway.go 76.72% <100.00%> (+1.08%) ⬆️
utils/hash.go 100.00% <100.00%> (ø)
...gins/jsonschema_validator/jsonschema/jsonschema.go 84.21% <84.21%> (ø)
utils/validate.go 84.09% <86.95%> (+0.75%) ⬆️
plugins/jsonschema_validator/plugin.go 76.27% <76.27%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cchenggit cchenggit force-pushed the feat/plugin-jsonschema-validator branch from d4f58ec to 6166e8d Compare September 21, 2025 11:48
@cchenggit cchenggit marked this pull request as ready for review September 21, 2025 12:02
@cchenggit cchenggit requested a review from vm-001 September 21, 2025 12:02
Copy link
Collaborator

@vm-001 vm-001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • default_schema: to be used when event_type is not defined in the schemas
  • version: define the jsonschema dialect version

"encoding/hex"
)

func Hash256(s string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sha256 is more accurate

"time"
)

type Config struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requires a version field. (enum: draft4/draft6/draft7/etc..)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current jsonschema only support openapi3 schema, which based on the draft6

RawBody: body,
})
if err != nil {
if validateErr, ok := err.(*errs.ValidateError); ok {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be handled inside the plugin?

}

type SchemaResource struct {
JSONString string `json:"json" validate:"omitempty,json,max=1048576"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use json:"schema"

Schemas map[string]*SchemaResource `json:"schemas" validate:"dive,required"`
}

type EventTypeSchema struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this struct is used.

@vm-001
Copy link
Collaborator

vm-001 commented Sep 22, 2025

I think we can design a feature to support loading values from external system(including file, env, and network), this would be a different topic. Let's remove the part of loading schema from the file and network to keep the plugin as simple as possible.

@cchenggit
Copy link
Collaborator Author

cchenggit commented Sep 22, 2025

I think we can design a feature to support loading values from external system(including file, env, and network), this would be a different topic. Let's remove the part of loading schema from the file and network to keep the plugin as simple as possible.

good idea, this should the common requirement of plugin

@vm-001
Copy link
Collaborator

vm-001 commented Sep 23, 2025

Please update the README.md to mention this cool plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants