go-openapi / validate

openapi toolkit validation helpers
Apache License 2.0
119 stars 53 forks source link

Quick Question - Is this the package I could use for a model validation? #8

Closed alphacentory closed 8 years ago

alphacentory commented 8 years ago

Is this the package I would use for model validation?

casualjim commented 8 years ago

this package has the code for validation of spec, schema, parameters, models and discrete values.

discrete values: https://github.com/go-openapi/validate/blob/master/values.go models: https://github.com/go-openapi/validate/blob/master/spec.go#L59 headers: https://github.com/go-openapi/validate/blob/master/validator.go#L177 parameter: https://github.com/go-openapi/validate/blob/master/validator.go#L281

alphacentory commented 8 years ago

ok that makes sense. For definitions, I am writing a validator to be schemaless using the "github.com/Jeffail/gabs" package, it might take a me a while to finish to spec, but where should that posted / contributed back to (would you want it)

These packages have been a blast, I have been writing a middleware for work on top of the golang echo server package.

casualjim commented 8 years ago

I don't think I fully understand :)

How does the gabs package compare with https://github.com/buger/jsonparser or https://github.com/mailru/easyjson

alphacentory commented 8 years ago

so the biggest difference is that gabs allows for a schemaless json object to built. So probably not a good substitution. What I am building is a piece of middleware for https://github.com/labstack/echo that is essentially two pieces of middleware. A validator and Responder.

So in the simplest explanation possible. A middleware router, that maps a schema to a full functioning api. I probably didn't use the operationId correctly. But that is what allows people to easily map to a handler. So an api tales ~100 lines if that, it includes: Rate limiting, Logic and response in the handler.

casualjim commented 8 years ago

right. have you seen the dynamic API server in go-swagger? https://github.com/go-swagger/go-swagger/blob/master/examples/2.0/petstore/server/api/petstore.go is it comparable to that? I would like to get some kind of contrib project going that gathers the external integrations.

yeah so operation id is not guaranteed to be unique or even always present. when we want unique names we use a mangling of method + path. This works in openapi 2.0 it will not work anymore in openapi 3.0. But it does sometimes result in very long type names etc

alphacentory commented 8 years ago

It is kind of comparable. I am more focusing on a way, for it to parse the scema and map to handlers all without any hard code. No structures for responses or validating. However is there a plan for the future of OAI to allow for the description of which handler the method / route will use?

If not my argument would be for documentation on using it, if the api throws an error, it could help developers and the api creator debug easier.

casualjim commented 8 years ago

you're fairly active, are you aware of https://slackin.goswagger.io/ ?

alphacentory commented 8 years ago

I am now. Thank you! My plan is to get my company to pay for the linux membership since I am, well I think I am doing some cool stuff using the Schema and packages.

casualjim commented 8 years ago

for influencing and contributing to the go version you don't need to be a member of the linux foundation.That's only if you want to influence the spec :)