Skip to content

Resolve $ref while walking #882

@alturkovic

Description

@alturkovic

I am trying to find property definitions which are required but do not have a value.

My current attempt:

private class MyCustomWalker : JsonSchemaWalkListener {
    override fun onWalkStart(walkEvent: WalkEvent) = WalkFlow.CONTINUE

    override fun onWalkEnd(walkEvent: WalkEvent, validationMessages: MutableSet<ValidationMessage>) {
        val field = walkEvent.at.substringAfterLast('.') // extract the field name
        val required = walkEvent.parentSchema.schemaNode["required"]?.contains(TextNode(field)) ?: false // check if that field is required

        if (required) {
            val type = walkEvent.schemaNode["type"] // get the field type
            // TODO resolve refs?
        }
    }
}

It is working pretty well, but I am having trouble resolving references. However I try resolving it, it fails with Couldn't find URI scheme: #/properties/myDto/properties/myField.

What is the proper way to do it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions