Skip to content

Commit

Permalink
[eclipse-ditto#903] provide OpenAPI documentation for /cloudevents on…
Browse files Browse the repository at this point in the history
… API 2

Signed-off-by: Thomas Jaeckle <[email protected]>
  • Loading branch information
thjaeckle committed Dec 10, 2020
1 parent 2a429c5 commit 674315d
Show file tree
Hide file tree
Showing 4 changed files with 336 additions and 0 deletions.
153 changes: 153 additions & 0 deletions documentation/src/main/resources/openapi/ditto-api-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ tags:
description: Find every thing
- name: Messages
description: Talk with your things
- name: CloudEvents
description: Process CloudEvents in Ditto
security:
- basicAuth: []
- bearerAuth: []
Expand Down Expand Up @@ -4858,6 +4860,157 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
/cloudevents:
post:
summary: Processes a CloudEvent sent in Ditto Protocol
description: |-
Provides an endpoint accepting [CloudEvents via its HTTP protocol binding](https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md)
in [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html).
The endpoint can also directly be configured as a [Knative eventing](https://knative.dev/docs/eventing/) destination.
Find more documentation on that [here](https://www.eclipse.org/ditto/httpapi-protocol-bindings-cloudevents.html).
tags:
- CloudEvents
parameters:
- in: header
name: ce-specversion
description: The CloudEvents "specversion".
schema:
type: string
example: '1.0'
required: true
- in: header
name: ce-type
description: The CloudEvents event "type".
schema:
type: string
example: com.example.someevent
required: true
- in: header
name: ce-source
description: The CloudEvents event "source".
schema:
type: string
example: /mycontext
required: true
- in: header
name: ce-id
description: The CloudEvents event "id".
schema:
type: string
example: 1234-1234-1234
required: true
- in: header
name: ce-time
description: The CloudEvents event "time".
schema:
type: string
format: date-time
example: '2020-12-31T23:59:59Z'
required: true
- in: header
name: ce-dataschema
description: 'The CloudEvents event "dataschema". If provided, this must start with `ditto:`.'
schema:
type: string
required: false
responses:
'202':
description: 'The Ditto Protocol CloudEvent was successfully parsed, the authentication was valid and also reached the persistence.'
'400':
description: |-
The request could not be completed. Possible reasons:
* the CloudEvent could not be parsed as some mandatory CloudEvent headers were missing from the request
* the payload was missing from the CloudEvent
* the [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html) message could not be parsed or was missing a required field
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
'401':
description: The request could not be completed due to missing authentication.
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
'403':
description: |-
The request could not be completed. Possible reasons:
* the caller has insufficient permissions.
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
'404':
description: |-
The request could not be completed. Possible reasons:
* the referenced thing does not exist.
* the caller has insufficient permissions to perform the contained Ditto Protocol command.
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
'408':
description: The request could not be completed due to timeout.
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
'415':
description: The `Content-Type` of the request was not supported.
content:
application/json:
schema:
$ref: '#/components/schemas/AdvancedError'
requestBody:
content:
application/vnd.eclipse.ditto+json:
schema:
type: object
properties:
topic:
type: string
description: |-
Contains information about the contents of the payload:
* the affected Thing (namespace and Thing ID)
* the type of operation (command/event, create/retrieve/modify/delete)
example: org.eclipse.ditto/thing-1/things/twin/commands/modify
headers:
type: object
description: Additional headers.
properties:
correlation-id:
type: string
description: |-
The correlation-id header is used for linking one message with another.
It typically links a reply message with its requesting message.
example:
correlation-id: 1234-4321-1234
path:
type: string
description: References the part of a Thing which is affected by this message.
example: /features/location/properties/longitude
value:
oneOf:
- type: object
- type: string
- type: number
- type: array
- type: boolean
description: The `value` field contains the actual payload e.g. a sensor value.
required:
- topic
- path
example:
topic: org.eclipse.ditto/thing-1/things/twin/commands/modify
path: /
value:
attributes:
foo: 42
description: |-
The [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html) payload defining which
command to process.
components:
responses:
EntityTooLarge:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ tags:
description: Find every thing
- name: Messages
description: Talk with your things
- name: CloudEvents
description: Process CloudEvents in Ditto

security:
# - Google:
Expand Down Expand Up @@ -126,6 +128,12 @@ paths:
/search/things/count:
$ref: "./paths/search/things-count.yml"

###
### CloudEvents
###
'/cloudevents':
$ref: "./paths/cloudevents/cloudevents.yml"

components:

responses:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Copyright (c) 2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
post:
summary: Processes a CloudEvent sent in Ditto Protocol
description: |-
Provides an endpoint accepting [CloudEvents via its HTTP protocol binding](https://github.com/cloudevents/spec/blob/v1.0/http-protocol-binding.md)
in [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html).
The endpoint can also directly be configured as a [Knative eventing](https://knative.dev/docs/eventing/) destination.
Find more documentation on that [here](https://www.eclipse.org/ditto/httpapi-protocol-bindings-cloudevents.html).
tags:
- CloudEvents
parameters:
- in: header
name: ce-specversion
description: The CloudEvents "specversion".
schema:
type: string
example: "1.0"
required: true
- in: header
name: ce-type
description: The CloudEvents event "type".
schema:
type: string
example: "com.example.someevent"
required: true
- in: header
name: ce-source
description: The CloudEvents event "source".
schema:
type: string
example: "/mycontext"
required: true
- in: header
name: ce-id
description: The CloudEvents event "id".
schema:
type: string
example: "1234-1234-1234"
required: true
- in: header
name: ce-time
description: The CloudEvents event "time".
schema:
type: string
format: date-time
example: "2020-12-31T23:59:59Z"
required: true
- in: header
name: ce-dataschema
description: The CloudEvents event "dataschema". If provided, this must start with `ditto:`.
schema:
type: string
required: false
responses:
'202':
description: |-
The Ditto Protocol CloudEvent was successfully parsed, the authentication was valid and also reached the persistence.
'400':
description: |-
The request could not be completed. Possible reasons:
* the CloudEvent could not be parsed as some mandatory CloudEvent headers were missing from the request
* the payload was missing from the CloudEvent
* the [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html) message could not be parsed or was missing a required field
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
'401':
description: The request could not be completed due to missing authentication.
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
'403':
description: |-
The request could not be completed. Possible reasons:
* the caller has insufficient permissions.
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
'404':
description: |-
The request could not be completed. Possible reasons:
* the referenced thing does not exist.
* the caller has insufficient permissions to perform the contained Ditto Protocol command.
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
'408':
description: The request could not be completed due to timeout.
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
'415':
description: The `Content-Type` of the request was not supported.
content:
application/json:
schema:
$ref: '../../schemas/advancedError.yml'
requestBody:
$ref: '../../requests/dittoProtocol.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (c) 2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
content:
application/vnd.eclipse.ditto+json:
schema:
type: object
properties:
topic:
type: string
description: |-
Contains information about the contents of the payload:
* the affected Thing (namespace and Thing ID)
* the type of operation (command/event, create/retrieve/modify/delete)
example: "org.eclipse.ditto/thing-1/things/twin/commands/modify"
headers:
type: object
description: Additional headers.
properties:
correlation-id:
type: string
description: |-
The correlation-id header is used for linking one message with another.
It typically links a reply message with its requesting message.
example:
correlation-id: "1234-4321-1234"
path:
type: string
description: References the part of a Thing which is affected by this message.
example: "/features/location/properties/longitude"
value:
oneOf:
- type: "object"
- type: "string"
- type: "number"
- type: "array"
- type: "boolean"
description: The `value` field contains the actual payload e.g. a sensor value.
required:
- topic
- path
example: {
"topic": "org.eclipse.ditto/thing-1/things/twin/commands/modify",
"path": "/",
"value": {
"attributes": {
"foo": 42
}
}
}
description: |-
The [Ditto Protocol JSON](https://www.eclipse.org/ditto/protocol-specification.html) payload defining which
command to process.

0 comments on commit 674315d

Please sign in to comment.