Skip to content
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

should InterceptType be called after options applied? #81

Open
Rainshaw opened this issue Apr 7, 2023 · 1 comment
Open

should InterceptType be called after options applied? #81

Rainshaw opened this issue Apr 7, 2023 · 1 comment

Comments

@Rainshaw
Copy link

Rainshaw commented Apr 7, 2023

jsonschema-go/reflect.go

Lines 229 to 244 in d4b7536

rc := ReflectContext{}
rc.Context = context.Background()
rc.DefinitionsPrefix = "#/definitions/"
rc.PropertyNameTag = "json"
rc.Path = []string{"#"}
rc.typeCycles = make(map[refl.TypeString]bool)
InterceptType(checkSchemaSetup)(&rc)
for _, option := range r.DefaultOptions {
option(&rc)
}
for _, option := range options {
option(&rc)
}

the rc instance does not set InterceptProperty filed, so the L236 just set rc.InterceptProperty = checkSchemaSetup.

When the options applied, the InterceptProperty would be rewrite.

@vearutop
Copy link
Member

That depends on how rc.InterceptType is handled.
If jsonschema.InterceptType function is used, original interceptor will be preserved and new one would be added to the chain.
But it is also possible to replace rc.InterceptType and discard all prev configuration, that's up to a developer.

Though, this is not so relevant now, as exported rc.InterceptType has got deprecated in favor of unexported rc.interceptSchema and jsonschema.InterceptSchema config option.

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

No branches or pull requests

2 participants