These are chat archives for APIs-guru/api-models

10th
Sep 2016
Mike Ralphson
@MikeRalphson
Sep 10 2016 04:36
@IvanGoncharov thanks, I will do. I will also look at adding a check to various validators/parsers. Has there been any more progress on your swagger-linter?
here is short summary of what we trying to do
@MikeRalphson We decided to go long way starting from scratch
we can't use standard JSON Schema for swagger since it will produce errors like that https://cloud.githubusercontent.com/assets/8336157/13833530/64665676-ebef-11e5-8c44-2e635f2361fc.jpg
also we constantly straggling with JSON Schema when we do consulting for our clients
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 10:47
we want to describe complex JSON object with 'switch' construct like that
and we want to support hooks on top schema https://github.com/json-struct/json-struct#support-for-iteration
so linter will be extensible
but it long process, right now we finishing alpha version of json-struct powered validator
than we will make it validate swagger files
Mike Ralphson
@MikeRalphson
Sep 10 2016 10:50
I think I understand, so many checks (including property dependencies) can be achieved with your new schema/grammar rather than with hard coding?
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 10:50
after that we will start working on hooks feature
yes for example bug that you found should be handled here
so idea is to separate checks from validation constraints
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 10:55
so error message will say, something like: "Since 'type' is 'integer' you can't add 'maxLength', it reserved for objects with 'type' equal to 'string'".
it will require to looking into other cases of the switch and figuring out how to better present error
so first version will say: Unexpected property "maxLength"
but even that is a big progress
and we can extend error reporting in the future version
plus you will be able hook a function to #/definitions/jsonSchemaStringConstraintsMixin and do your own checks
for example validate regexp syntax
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 11:01
@MikeRalphson It would be great to hear your thoughts about json-struct.
there is not many docs at the moment
they have URLs to origin JSON Schema at the top
so you can compare
we feel this project too big for APIs.guru so we extracted it into separate GitHub org + bought "json-struct.org" domain
and looking for projects/companies to collaborate with
Mike Ralphson
@MikeRalphson
Sep 10 2016 11:21
@IvanGoncharov excellent. I had spotted json-struct and had a look at the 'differences' doc, but did not fully understand the impetus behind the project, nor realise it was linked to OpenAPI-lint. A recent commit message should have given me the hint!
Maybe the best way for me to learn about json-struct is to try and raise a PR for this issue (or a subset of it)?
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 11:27
PR to json-struct repo?
if you speak about json-struct document to validate OpenAPI specs
it's already handled there
see this trace
so maxLength defined only if type equal string and validator use this case
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 11:33
switch{foo} will extend current object based on value of property foo
=<JSON value> === { "enum": [ <JSON value> ] }
="integer" === { "enum": [ "integer"] }
think of switch as oneOf where "condition" separated from schema that applied if "condition" matched
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 11:39
we wanted to introduce something simular to OpenAPI scheme object instead of discriminator OAI/OpenAPI-Specification#707
but it after giving it a though it looks like this:
or this
Mike Ralphson
@MikeRalphson
Sep 10 2016 11:42
😆
Ivan Goncharov
@IvanGoncharov
Sep 10 2016 11:44
plan to make a talk at RestFest so preparing finny slides