mservicetech / openapi-schema-validation

Apache License 2.0
15 stars 9 forks source link

Need to provide VersionFlag to `JsonSchemaFactory.getInstance()` #51

Open eddie-atkinson opened 2 months ago

eddie-atkinson commented 2 months ago

I am trying to set this up in a project running the following versions of dependencies:

    implementation("com.networknt:json-schema-validator:1.4.0")
    implementation("com.mservicetech:openapi-schema-validation:2.0.8")

It's a simple Spring Boot Web app with the following controller:

@RestController
@RequestMapping(value = ["/v1/inputs", "/inputs"])
class InputsController(val apiValidator: OpenApiValidator) {
    @PostMapping(consumes = [MediaType.APPLICATION_JSON_VALUE])
    fun postInputs(
        @RequestBody
        body: String,
    ): ResponseEntity<Any> 
        val requestEntity = RequestEntity()
        requestEntity.requestBody = body
        val validation = apiValidator.validateRequestPath("/inputs", "post", requestEntity)
        return ResponseEntity.ok("OK")
    }
}

Following the thread of execution I found the call and the error is pretty clear in my IDE:

image

I'm happy to provide a PR to fix this, but I was wondering what you wanted the behaviour to be? It feels to me like we could just add something onto the configuration for the OpenApiValidator so people could override the behaviour if they wanted to but then just set a sensible default.

What do you think?