From 12d980a296babffb1731d421ab3342f9a299cbcd Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Sun, 9 Mar 2025 11:27:52 +0100 Subject: [PATCH] Generate GeoJSON for topology - reuse existing GeoJSON yaml - add RFC7946 control parameter to schema IssueID: OAM-443 Change-Id: I0e616e4efef6f55bf3168b3f94bbecb70bb4ff05 Signed-off-by: Martin Skorupski --- .../model/jsonSchema/configuration.schema.json | 41 +- .../model/jsonSchema/geojson.oas.yaml | 585 +++++++++++++++++++++ 2 files changed, 620 insertions(+), 6 deletions(-) create mode 100644 code/network-generator/network_generation/model/jsonSchema/geojson.oas.yaml diff --git a/code/network-generator/network_generation/model/jsonSchema/configuration.schema.json b/code/network-generator/network_generation/model/jsonSchema/configuration.schema.json index c1512d5..fdbfd44 100644 --- a/code/network-generator/network_generation/model/jsonSchema/configuration.schema.json +++ b/code/network-generator/network_generation/model/jsonSchema/configuration.schema.json @@ -40,7 +40,19 @@ "type": "string", "pattern": "^[a-zA-Z]{1}[\\S]{0,254}$" }, - + "host": { + "description": "The host exposing a northbound REST interface.", + "type": "string", + "format": "uri" + }, + "version": { + "description": "A version sting in format 'v0.0.0' to be used in TMF APIs.", + "type": "string" + }, + "center": { + "description": "Defines the geographical center of the Radio Access Network.", + "$ref": "#/$defs/geoLocation" + }, "disabledResourcesProfile": { "description": "A definition how many resource in percentage should be disabled for each network resource type (e.g. O-DU, Cell, ...). The value is network topology node type (resource type) individual per type.", "$ref": "#/$defs/DisabledResourcesProfile" @@ -49,10 +61,6 @@ "description": "Defines enumerated operational states aligned with ITU-T usage. Please see ITU-T M.3100: 'Generic Managed Entities' and ITU-T M.3160: 'Generic Management Information Model'", "$ref": "#/$defs/OperationalState" }, - "center": { - "description": "Defines the geographical center of the Radio Access Network.", - "$ref": "#/$defs/geoLocation" - }, "pattern": { "description": "A description of the relations between O-RAN Objects.", "$ref": "#/$defs/pattern" @@ -315,7 +323,8 @@ "required": [ "rfc8345", "svg", - "kml" + "kml", + "rfc7946" ], "additionalProperties": false, "properties": { @@ -335,9 +344,29 @@ "description": "If enabled, a kml file will be generated.", "$ref": "#/$defs/export" }, + "rfc7946": { + "description": "If enabled, a geojson file will be generated.", + "$ref": "#/$defs/export" + }, "teiv": { "description": "If enabled, a teiv data file will be generated.", "$ref": "#/$defs/export" + }, + "tmf632": { + "description": "If enabled, a json file will be generated according to TMF632 party.", + "$ref": "#/$defs/export" + }, + "tmf633": { + "description": "If enabled, a json file will be generated according to TMF633 service catalog.", + "$ref": "#/$defs/export" + }, + "tmf634": { + "description": "If enabled, a json file will be generated according to TMF634 resource catalog.", + "$ref": "#/$defs/export" + }, + "tmf686": { + "description": "If enabled, a json file will be generated according to TMF686.", + "$ref": "#/$defs/export" } } }, diff --git a/code/network-generator/network_generation/model/jsonSchema/geojson.oas.yaml b/code/network-generator/network_generation/model/jsonSchema/geojson.oas.yaml new file mode 100644 index 0000000..4f228b1 --- /dev/null +++ b/code/network-generator/network_generation/model/jsonSchema/geojson.oas.yaml @@ -0,0 +1,585 @@ +openapi: 3.0.0 +info: + version: 1.0.1 + title: GeoJSON format + description: > + This document defines the GeoJSON format as an OpenAPI. + It contains the definitions for 'Feature' object and 'FeatureCollection' + objects, as well as the definitions for all 'Geometry' objects. + It conforms with the 'RFC-7946' standard from IETF (August 2016 version) + + Kudos to @bubbobne and @idkw whose code helped me not start from scratch + https://gist.github.com/bubbobne/fe5f2db65acf039be6a9fd92fc9c7233 + + termsOfService: 'no' + contact: + name: Zitoun + email: 'zitoun@gmail.com' + license: + name: GPLv3 + url: 'https://www.gnu.org/licenses/gpl-3.0.html' + +#••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +externalDocs: + description: 'Official GeoJSON specification – IETF RFC-7946 (August 2016)' + url: 'https://tools.ietf.org/html/rfc7946' + +#••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +security: + - UserSecurity: [] + +#••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +servers: + - url: 'http://myHost/' + +#••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +paths: + #============================================================================= + '/geometry': + get: + summary: Get an array of GeoJSON Geometry objects + responses: + '200': + description: Successful response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GeometryCollection' + '400': + $ref: '#/components/responses/Error400BadRequest' + '401': + $ref: '#/components/responses/Error401Unauthorized' + '500': + $ref: '#/components/responses/Error500InternalServerError' + post: + summary: Create new GeoJSON Geometry object + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Geometry' + required: true + responses: + '201': + description: New GeoJSON Geometry object created + '400': + $ref: '#/components/responses/Error400BadRequest' + '401': + $ref: '#/components/responses/Error401Unauthorized' + '403': + $ref: '#/components/responses/Error403Forbidden' + '500': + $ref: '#/components/responses/Error500InternalServerError' + +#••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +components: + + #============================================================================= + schemas: + + #--------------------------------------------------------------------------- + 'GeoJsonObject': + description: > + GeoJSon object + + The coordinate reference system for all GeoJSON coordinates is a + geographic coordinate reference system, using the World Geodetic System + 1984 (WGS 84) datum, with longitude and latitude units of decimal + degrees. + This is equivalent to the coordinate reference system identified by the + Open Geospatial Consortium (OGC) URN + An OPTIONAL third-position element SHALL be the height in meters above + or below the WGS 84 reference ellipsoid. + In the absence of elevation values, applications sensitive to height or + depth SHOULD interpret positions as being at local ground or sea level. + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3' + type: object + properties: + 'type': + type: string + enum: + - Feature + - FeatureCollection + - Point + - MultiPoint + - LineString + - MultiLineString + - Polygon + - MultiPolygon + - GeometryCollection + 'bbox': + description: > + A GeoJSON object MAY have a member named "bbox" to include + information on the coordinate range for its Geometries, Features, or + FeatureCollections. The value of the bbox member MUST be an array of + length 2*n where n is the number of dimensions represented in the + contained geometries, with all axes of the most southwesterly point + followed by all axes of the more northeasterly point. The axes order + of a bbox follows the axes order of geometries. + type: array + items: + type: number + required: + - type + discriminator: + propertyName: type + + #--------------------------------------------------------------------------- + 'Geometry': + description: > + Abstract type for all GeoJSon object except Feature and + FeatureCollection + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3' + allOf: + - $ref: '#/components/schemas/GeoJsonObject' + - type: object + properties: + 'type': + type: string + enum: + - Point + - MultiPoint + - LineString + - MultiLineString + - Polygon + - MultiPolygon + - GeometryCollection + required: + - type + discriminator: + propertyName: type + + #--------------------------------------------------------------------------- + 'GeometryElement': + description: > + Abstract type for all GeoJSon 'Geometry' object the type of which is not + 'GeometryCollection' + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3' + allOf: + - $ref: '#/components/schemas/Geometry' + - type: object + properties: + 'type': + type: string + enum: + - Point + - MultiPoint + - LineString + - MultiLineString + - Polygon + - MultiPolygon + required: + - type + discriminator: + propertyName: type + + #--------------------------------------------------------------------------- + 'Feature': + description: GeoJSon 'Feature' object + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.2' + allOf: + - $ref: '#/components/schemas/GeoJsonObject' + - type: object + required: + - geometry + - properties + properties: + 'geometry': + allOf: + - nullable: true + - $ref: '#/components/schemas/Geometry' + 'properties': + type: object + nullable: true + 'id': + oneOf: + - type: number + - type: string + + #--------------------------------------------------------------------------- + 'FeatureCollection': + description: GeoJSon 'FeatureCollection' object + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.3' + allOf: + - $ref: '#/components/schemas/GeoJsonObject' + - type: object + required: + - features + properties: + 'features': + type: array + items: + $ref: '#/components/schemas/Feature' + + #--------------------------------------------------------------------------- + 'Position': + description: > + GeoJSon fundamental geometry construct. + + A position is an array of numbers. There MUST be two or more elements. + The first two elements are longitude and latitude, or easting and + northing, precisely in that order and using decimal numbers. + Altitude or elevation MAY be included as an optional third element. + + Implementations SHOULD NOT extend positions beyond three elements + because the semantics of extra elements are unspecified and ambiguous. + Historically, some implementations have used a fourth element to carry + a linear referencing measure (sometimes denoted as "M") or a numerical + timestamp, but in most situations a parser will not be able to properly + interpret these values. The interpretation and meaning of additional + elements is beyond the scope of this specification, and additional + elements MAY be ignored by parsers. + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.1' + type: array + minItems: 2 + maxItems: 3 + items: + type: number + + #--------------------------------------------------------------------------- + 'LineStringCoordinates': + description: > + GeoJSon fundamental geometry construct, array of two or more positions. + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.4' + type: array + items: + $ref: '#/components/schemas/Position' + minItems: 2 + + #--------------------------------------------------------------------------- + 'LinearRing': + description: > + A linear ring is a closed LineString with four or more positions. + + The first and last positions are equivalent, and they MUST contain + identical values; their representation SHOULD also be identical. + + A linear ring is the boundary of a surface or the boundary of a hole in + a surface. + + A linear ring MUST follow the right-hand rule with respect to the area + it bounds, i.e., exterior rings are counterclockwise, and holes are + clockwise. + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.6' + type: array + items: + $ref: '#/components/schemas/Position' + minItems: 4 + + #--------------------------------------------------------------------------- + 'Point': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.2' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - type + - coordinates + properties: + 'type': + type: 'string' + enum: [Point] + 'coordinates': + $ref: '#/components/schemas/Position' + + #--------------------------------------------------------------------------- + 'MultiPoint': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.3' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - coordinates + properties: + 'coordinates': + type: array + items: + $ref: '#/components/schemas/Position' + + #--------------------------------------------------------------------------- + 'LineString': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.4' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - coordinates + properties: + 'coordinates': + $ref: '#/components/schemas/LineStringCoordinates' + + #--------------------------------------------------------------------------- + 'MultiLineString': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.5' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - coordinates + properties: + 'coordinates': + type: array + items: + $ref: '#/components/schemas/LineStringCoordinates' + + #--------------------------------------------------------------------------- + 'Polygon': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.6' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - coordinates + properties: + 'coordinates': + type: array + items: + $ref: '#/components/schemas/LinearRing' + + #--------------------------------------------------------------------------- + 'MultiPolygon': + description: GeoJSon geometry + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.7' + allOf: + - $ref: '#/components/schemas/GeometryElement' + - type: object + required: + - coordinates + properties: + 'coordinates': + type: array + items: + type: array + items: + $ref: '#/components/schemas/LinearRing' + + #--------------------------------------------------------------------------- + 'GeometryCollection': + type: object + description: > + GeoJSon geometry collection + + GeometryCollections composed of a single part or a number of parts of a + single type SHOULD be avoided when that single part or a single object + of multipart type (MultiPoint, MultiLineString, or MultiPolygon) could + be used instead. + externalDocs: + url: 'https://tools.ietf.org/html/rfc7946#section-3.1.8' + allOf: + - $ref: '#/components/schemas/Geometry' + - type: object + required: + - geometries + properties: + 'geometries': + type: array + items: + $ref: '#/components/schemas/GeometryElement' + minItems: 0 + + #============================================================================= + responses: + + #--------------------------------------------------------------------------- + 'Error400BadRequest': + description: The JSON is not valid. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [400] + 'message': + type: string + enum: ['The JSON is not valid.'] + #--------------------------------------------------------------------------- + 'Error401Unauthorized': + description: The request requires an user authentication. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [401] + 'message': + type: string + enum: ['The request requires an user authentication.'] + #--------------------------------------------------------------------------- + 'Error403Forbidden': + description: The access is not allowed. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [403] + 'message': + type: string + enum: ['The access is not allowed.'] + #--------------------------------------------------------------------------- + 'Error404NotFound': + description: The resource was not found. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [404] + 'message': + type: string + enum: ['The resource was not found.'] + #--------------------------------------------------------------------------- + 'Error405MethodNotAllowed': + description: + Request method is not supported for the requested resource. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [405] + 'message': + type: string + enum: ['Request method is not supported for the requested resource.'] + #--------------------------------------------------------------------------- + 'Error406NotAcceptable': + description: + Headers sent in the request are not compatible with the service. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [406] + 'message': + type: string + enum: ['Headers sent in the request are not compatible with the service.'] + #--------------------------------------------------------------------------- + 'Error408RequestTimeout': + description: > + The client did not produce a request within the time that the server was + prepared to wait. The client may repeat the request without + modifications at any later time. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [408] + 'message': + type: string + enum: ['The client did not produce a request within the time that the server was prepared to wait. The client may repeat the request without modifications at any later time.'] + #--------------------------------------------------------------------------- + 'Error410Gone': + description: > + The requested resource is no longer available and will not be available + again. The resource should be purged from the client system. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [410] + 'message': + type: string + enum: ['The requested resource is no longer available and will not be available again. The resource should be purged from the client system.'] + #--------------------------------------------------------------------------- + 'Error423Locked': + description: The resource that is being accessed is locked. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [423] + 'message': + type: string + enum: ['The resource that is being accessed is locked.'] + #--------------------------------------------------------------------------- + 'Error429TooManyRequests': + description: The user has sent too many requests in a short period. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [429] + 'message': + type: string + enum: ['The user has sent too many requests in a short period.'] + #--------------------------------------------------------------------------- + 'Error500InternalServerError': + description: An unexpected error occured. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [500] + 'message': + type: string + enum: ['An unexpected error occured.'] + #--------------------------------------------------------------------------- + 'Error503ServiceUnavailable': + description: The server is currently unable to handle the request. + content: + application/json: + schema: + type: object + properties: + 'status_code': + type: integer + enum: [503] + 'message': + type: string + enum: ['The server is currently unable to handle the request.'] + #============================================================================= + securitySchemes: + 'UserSecurity': + type: http + scheme: basic + +#•••••••••••••••••••••••••••••••••••[ EOF ]••••••••••••••••••••••••••••••••••••# \ No newline at end of file -- 2.16.6