Commit d0427c7c authored by canterafonsj's avatar canterafonsj
Browse files

Swagger Open API description migrated

parent ecbf3c61
.DS_Store
#!/bin/bash
#
# Requires install swagger-cli: npm install -g swagger-cli
#
# Store current directory
current_dir=${PWD}
# Store script directory
script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Move cd to the script directory (the script must be called from the 'script' directory)
cd $script_directory
# Generate a file which combines all the spec files into a unique swagger definition file (maintains references)
swagger-cli bundle ../spec/ngsild_swagger.json -o combined_spec/ngsild_swagger_combined.json
# Generate a file which combines all the spec files into a unique swagger definition file (removes references)
swagger-cli bundle -r ../spec/ngsild_swagger.json -o combined_spec/ngsild_swagger_combined_dereferenced.json
# Move cd to the directory from where the script was called
cd $current_dir
This diff is collapsed.
#!/bin/bash
#
# Requires install swagger-cli: npm install -g swagger-cli
#
# Store current directory
current_dir=${PWD}
# Store script directory
script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Move cd to the script directory (the script must be called from the 'script' directory)
cd $script_directory
# Validate locally the definition using the swagger-cli validate option
swagger-cli validate ../spec/ngsild_swagger.json
# Move cd to the directory from where the script was called
cd $current_dir
\ No newline at end of file
#!/bin/bash
#
# Requires install swagger-cli: npm install -g swagger-cli
#
# Store current directory
current_dir=${PWD}
# Store script directory
script_directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Move cd to the script directory (the script must be called from the 'script' directory)
cd $script_directory
# Merge the swagger definition into an unified and de-referenced file (use this file will avoid reference resolution problems during the validation)
swagger-cli bundle -r ../spec/ngsild_swagger.json -o combined_spec/ngsild_swagger_combined_dereferenced.json
# Validate the swagger definition against the official online swagger validation service
curl -X POST -d @combined_spec/ngsild_swagger_combined_dereferenced.json -H 'Content-Type:application/json' http://online.swagger.io/validator/debug
# Move cd to the directory from where the script was called
cd $current_dir
\ No newline at end of file
POST
/v2/csources
{
"source": {
"name": "My Context Source",
"description": "Context source example 1",
"endPoint": "http://broker.example.org/v2/entities",
"scope": {
"georel": "within",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-10.0, -10.0],
[10.0, -10.0],
[10.0, 10.0],
[-10.0, -10.0]
]
]
}
}
},
"dataProvided": {
"entities": [{
'id',
'type',
'typePattern'
'idPattern'
}],
"properties": [
"width"
]
},
"expires": ""
}
Properties cannot be empty array.
\ No newline at end of file
This diff is collapsed.
{
"definitions": {
"CsourceRegistrationParams": {
"allOf": [
{
"type": "object",
"properties": {
"timestamp": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "ngsild_schema.json#/definitions/TimeInterval"
}
},
"location": {
"$ref": "http://json.schemastore.org/geojson#/definitions/geometry"
},
"expires": {
"type": "string",
"format": "date-time"
},
"name": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string",
"minLength": 1
}
}
},
{
"$ref": "ngsild_schema.json#/definitions/AtContext"
}
]
},
"CsourceRegistrationMandatoryParams": {
"type": "object",
"required": [
"endpoint",
"type",
"information"
],
"properties": {
"endpoint": {
"type": "string",
"format": "uri"
},
"type": {
"type": "string",
"enum": [
"ContextSourceRegistration"
]
},
"information": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "ngsild_schema.json#/definitions/RegistrationInfo"
}
}
}
},
"CsourceRegistration": {
"allOf": [
{
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "ngsild_schema.json#/definitions/CommonMembers"
},
{
"$ref": "#/definitions/CsourceRegistrationParams"
},
{
"$ref": "#/definitions/CsourceRegistrationMandatoryParams"
}
]
},
"CsourceRegistrationDescription": {
"allOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "#/definitions/CsourceRegistrationParams"
},
{
"$ref": "#/definitions/CsourceRegistrationMandatoryParams"
}
]
},
"CsourceRegistrationFragment": {
"allOf": [
{
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"format": "uri"
},
"endpoint": {
"type": "string",
"format": "uri"
},
"type": {
"type": "string",
"enum": [
"ContextSourceRegistration"
]
},
"information": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "ngsild_schema.json#/definitions/RegistrationInfo"
}
}
}
},
{
"$ref": "#/definitions/CsourceRegistrationParams"
}
]
},
"CsourceRegistrationList": {
"type": "array",
"items": {
"$ref": "#/definitions/CsourceRegistration"
}
}
}
}
{
"definitions": {
"EntityParams": {
"allOf": [
{
"type": "object",
"properties": {
"location": {
"$ref": "ngsild_schema.json#/definitions/GeoProperty"
},
"observationSpace": {
"$ref": "ngsild_schema.json#/definitions/GeoProperty"
},
"operationSpace": {
"$ref": "ngsild_schema.json#/definitions/GeoProperty"
}
}
},
{
"$ref": "ngsild_schema.json#/definitions/AtContext"
}
]
},
"EntityMandatoryParams": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string",
"minLength": 1
}
}
},
"Entity": {
"allOf": [
{
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "#/definitions/EntityMandatoryParams"
},
{
"$ref": "#/definitions/EntityParams"
},
{
"$ref": "ngsild_schema.json#/definitions/CommonMembers"
}
]
},
"EntityDescription": {
"allOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "#/definitions/EntityMandatoryParams"
},
{
"$ref": "#/definitions/EntityParams"
}
]
},
"EntityFragment": {
"allOf": [
{
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "#/definitions/EntityMandatoryParams"
},
{
"$ref": "#/definitions/EntityParams"
}
]
},
"EntityAttrList": {
"allOf": [
{
"$ref": "#/definitions/EntityMandatoryParams"
},
{
"$ref": "#/definitions/EntityParams"
}
]
},
"EntityList": {
"type": "array",
"items": {
"$ref": "#/definitions/Entity"
}
}
}
}
{
"definitions": {
"ApiErrorResponse": {
"type": "object",
"properties": {
"type": {
"type": "string",
"format": "uri"
},
"title": {
"type": "string"
},
"detail": {
"type": "string"
}
}
},
"CommonMembers": {
"type": "object",
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
},
"modifiedAt": {
"type": "string",
"format": "date-time"
}
}
},
"observedMember": {
"type": "object",
"properties": {
"observedAt": {
"type": "string",
"format": "date-time"
}
}
},
"AtContext": {
"type": "object",
"properties": {
"@context": {
"type": ["string","object","array"]
}
}
},
"PropertyCommonData": {
"allOf": [
{
"type": "object",
"properties": {
"unitCode": {
"type": "string"
}
}
},
{
"$ref": "#/definitions/observedMember"
}
]
},
"Property": {
"allOf": [
{
"type": "object",
"required": ["type", "value"],
"properties": {
"type": {
"type": "string",
"enum": ["Property"]
},
"value": {}
}
},
{
"$ref": "#/definitions/CommonMembers"
},
{
"$ref": "#/definitions/PropertyCommonData"
}
]
},
"Relationship": {
"allOf": [
{
"type": "object",
"required": ["type", "object"],
"properties": {
"type": {
"type": "string",
"enum": ["Relationship"]
},
"object": {
"type": "string",
"format": "uri"
}
}
},
{
"$ref": "#/definitions/CommonMembers"
},
{
"$ref": "#/definitions/observedMember"
}
]
},
"GeoProperty": {
"allOf" : [
{
"type": "object",
"required": ["type", "value"],
"properties": {
"type": {
"type": "string",
"enum": [
"GeoProperty"
]
},
"value": {
"$ref": "http://json.schemastore.org/geojson#/definitions/geometry"
}
}
},
{
"$ref": "#/definitions/observedMember"
}
]
},
"EntityInfo": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "string"
},
"idPattern": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"EntityInfo_correct_definition_not_compilable_in_swagger_2_0": {
"anyOf": [
{
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "string"
}
}
},
{
"type": "object",
"required": ["idPattern"],
"properties": {
"idPattern": {
"type": "string"
}
}
},
{
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string"
}
}
}
]
},
"RegistrationInfo": {
"type": "object",
"required": ["entities"],
"properties": {
"entities": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/definitions/EntityInfo"
}
},
"properties": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
},
"uniqueItems": true
},
"relationships": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
},
"uniqueItems": true
}
}
},
"TimeInterval" : {
"type": "object",
"required": ["start"],
"properties": {
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
}
}
},
"GeoQuery" : {
"type": "object",
"required": ["geometry","coordinates","georel"],
"properties": {