Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wouter van der Beek (wovander) committed Mar 3, 2020
1 parent 2fcf960 commit 2269460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 284 deletions.
8 changes: 7 additions & 1 deletion src/templates/SDF2OAS/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

Converts SDF files to OAS2.0 files.

usage:
input options to use:

-swagger <filename>, the input SDF file
-template SDF2OAS, the template to convert SDF to OAS2.0
-out_dir <foldername>, the folder for the output_file
-jsonindent <number>, nice format JSON with indent = 2
-output_file <myfilename>, the output filename, should end with .swagger.json

fixed parameters:
- rt values are created as oic.r.XXXX where XXXX is the odmObject name.
will also be done for models that are not originating from OCF.
- if parameter block
this is fixed in the template, e.g. all OAS files will have the same set of interfaces
284 changes: 1 addition & 283 deletions test/out/testcase_5/testcase_5.txt
Original file line number Diff line number Diff line change
@@ -1,283 +1 @@
************************
swagger2x 20171123
************************
file : ../test/in/test_swagger_5/TemperatureResURI.swagger.json
out_dir : ./out/testcase_5/
schema : None
schemadir : .
template : NodeIotivityServer
template_dir : ../src/templates

uuid : 9b8fadc6-1e57-4651-bab2-e268f89f3ea7
manufactorer : ocf.org

parse tree of input file:
{
"consumes": [
"application/json"
],
"definitions": {
"Temperature": {
"properties": {
"id": {
"description": "Instance ID of this specific resource",
"readOnly": true,
"type": "string"
},
"if": {
"description": "The interface set supported by this resource",
"items": {
"enum": [
"oic.if.baseline",
"oic.if.ll",
"oic.if.b",
"oic.if.lb",
"oic.if.rw",
"oic.if.r",
"oic.if.a",
"oic.if.s"
],
"type": "string"
},
"readOnly": true,
"type": "array"
},
"n": {
"description": "Friendly name of the resource",
"readOnly": true,
"type": "string"
},
"precision": {
"description": "Accuracy granularity of the exposed value",
"readOnly": true,
"type": "number"
},
"range": {
"description": "The valid range for the value Property",
"items": {
"anyOf": [
{
"type": "number"
},
{
"type": "integer"
}
]
},
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"rt": {
"description": "Resource Type",
"items": [
{
"maxLength": 64,
"type": "string"
}
],
"minItems": 1,
"readOnly": true,
"type": "array"
},
"step": {
"anyOf": [
{
"type": "integer"
},
{
"type": "number"
}
],
"description": "Step value across the defined range",
"readOnly": true
},
"temperature": {
"description": "Current temperature setting or measurement",
"type": "number"
},
"units": {
"description": "Units for the temperature value",
"enum": [
"C",
"F",
"K"
],
"readOnly": true
},
"value": {
"anyOf": [
{
"type": "array"
},
{
"type": "string"
},
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "number"
},
{
"type": "object"
}
],
"description": "The value sensed or actuated by this Resource"
}
},
"required": [
"temperature"
],
"type": "object"
}
},
"info": {
"license": {
"name": "copyright 2016-2017 Open Connectivity Foundation, Inc. All rights reserved.",
"x-description": "Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:@cr 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.@cr 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.@cr@cr THIS SOFTWARE IS PROVIDED BY THE Open Connectivity Foundation, INC. 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR WARRANTIES OF NON-INFRINGEMENT, ARE DISCLAIMED.@cr IN NO EVENT SHALL THE Open Connectivity Foundation, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)@cr HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.@cr"
},
"title": "OICTemperature",
"version": "v1.1.0-20160519"
},
"parameters": {
"interface": {
"enum": [
"oic.if.a",
"oic.if.s",
"oic.if.baseline"
],
"in": "query",
"name": "if",
"type": "string"
}
},
"paths": {
"/TemperatureResURI": {
"get": {
"description": "This resource describes a sensed or actuated Temperature value.@crThe temperature describes the current value measured.@crThe units is a single value that is one of C, F or K.@crIt provides the unit of measurement for the temperature value.@crIt is a read-only value that is provided by the server.@crIf the units Property is missing the default is Celsius [C].@crWhen range (from oic.r.baseresource) is omitted the default is +/- MAXINT.@crRetrieves the current temperature value.@crA client can specify the units for the requested temperature by use of a query parameter.@crIf no query parameter is provided the server provides its default measure or set value.@cr",
"parameters": [
{
"$ref": "#/parameters/interface"
},
{
"description": "Units",
"enum": [
"C",
"F",
"K"
],
"in": "query",
"name": "units",
"type": "string"
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/Temperature"
},
"x-example": {
"id": "unique_example_id",
"range": [
0.0,
100.0
],
"rt": [
"oic.r.temperature"
],
"temperature": 20.0,
"units": "C"
}
},
"403": {
"description": "This response is generated by the OIC Server when the client sends:@cr A retrieve with q queryParameter indicating a unit that the server does not support.@crThe server responds with the current resource representation including the@crunits property illustrating the supported units and the error.@cr",
"schema": {
"$ref": "#/definitions/Temperature"
},
"x-example": {
"id": "unique_example_id",
"temperature": 20.0,
"units": "C"
}
}
}
},
"post": {
"description": "Sets the desired temperature value.@crIf a unit is included and the server does not support the unit indictaed the request will fail.@crIf the units are omitted value is taken to be in C.@cr",
"parameters": [
{
"$ref": "#/parameters/interface"
},
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/Temperature"
},
"x-example": {
"id": "unique_example_id",
"temperature": 18.0
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/Temperature"
},
"x-example": {
"id": "unique_example_id",
"temperature": 18.0
}
},
"403": {
"description": "This response is generated by the OIC Server when the client sends:@cr An update with an out of range property value for temperature.@cr An update with an unsupported unit for this server.@crThe server responds with the current resource representation including@crthe range property illustrating the supported range and the error.@cr",
"schema": {
"$ref": "#/definitions/Temperature"
},
"x-example": {
"id": "unique_example_id",
"range": [
0.0,
100.0
],
"temperature": 20.0,
"units": "C"
}
}
}
}
}
},
"produces": [
"application/json"
],
"schemes": [
"http"
],
"swagger": "2.0"
}
processing: Server.js.jinja2
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
query_ref: reference: interface
copying template file: readme.txt
bash: C:\python35-32\python3.exe: No such file or directory

0 comments on commit 2269460

Please sign in to comment.