Skip to content

Conversation

@sguiheux
Copy link

@sguiheux sguiheux commented Sep 7, 2022

Hi,

To be a little more specific than the tag: "oneof_type=string,array", I add a new one that use "all_of" and condition to specify the type of field.

type Application struct {
    Name          string          `json:"name"`
    Kind          string          `json:"kind"`
    Specification json.RawMessage `json:"spec" jsonschema_allof_type:"kind=docker:#/$defs/dockerApp, kind=vm:#/$defs/vmApp"`
}

With this type of struct when the content of a field ( Specification ) depends of another one, we can specify in the jsonschema the right type, and make jsonschema validation works

As it does not affect directly the type of field ( because it adds a all_of on the parent ), I do not implements this in the tags jsonschema like oneof_type, cleaner and more readable

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.

1 participant