Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust spec version and add missing element #218

Merged
merged 4 commits into from
Sep 10, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion specification/quantumleap.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
swagger: '2.0' # For 3.0 see (https://github.com/zalando/connexion/issues/420)
info:
title: "QuantumLeap API"
version: "0.1.2"
version: "0.7" # we'll keep it aligned with QL version
host: "localhost:8668" # it'll run in the same container, hence localhost.
basePath: /v2
produces:
Expand Down Expand Up @@ -83,6 +83,7 @@ definitions:

ValuesArray:
type: array
items:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hairy. The Swagger 2 spec basically says it should be the same as items in the JSON schema:

but the JSON schema they refer to is v4:

which seems to say nothing about the meaning of items without a type. The Swagger 3 spec says:

Unlike JSON Schema, the items keyword is required in arrays. The value of items is a schema that describes the type and format of array items

which seems to imply you have to specify a type, but then again it isn't saying it explicitly.

What should we do then? Does this work in SwaggerHub? And does it work in Quantum Leap with response validation turned on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @c0c0n3, i think for openapi solution is very easy:
https://swagger.io/docs/specification/data-models/data-types/

check "Mixed-Type Arrays":

# ["foo", 5, -2, "bar"]
type: array
items:
  oneOf:
    - type: string
    - type: integer

i suspect we could have also array, object or whatever there.

another alternative if this is not enough, is refer to a schema that is "Any Type" (check the section in the same link above):

components:
  schemas:
    AnyValue: {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use AnyValue just to get the ball rolling when we make the switch to Swagger 3/Open API. Then I'd also like to use the oneOf attribute, but that will have to be kept in synch with the types we accept in the notifications which might require a bit more of thinking since we'll have to review the mapping we do on inserting entities.

In the meantime, since we have Swagger 2 but will soon update to 3, for my money this PR can go in as is as long as it:

  • works in SwaggerHub
  • works in QL w/ response validation turned off

@taliaga does it? :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, so it works on SwaggerHub and in QL with response validation off. Happy days!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your comments, we need to review the actually supported array types with QL (and either prevent or support mixed types).

The purpose of this PR was to align the versioning as requested. In the same go, I wanted to leave it clean of warnings (swagger validator was complaining about an array without items). Empty items was OK but I've checked now again and according to https://swagger.io/docs/specification/data-models/data-types/ it should have a {}.

This is just to keep consistency and remove warnings. As mentioned, we'll need to review the types altogether.

description: "Array of values of the selected attribute, in the same
corresponding order of the 'index' array. When using aggregation options,
the format of this remains the same, only the semantics will change. For
Expand Down