Skip to content

Instantly share code, notes, and snippets.

@zoenolan
Forked from codan-telcikt/geometry_geojson.yaml
Last active November 13, 2020 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoenolan/493a9c3c1dc505f987d3b5ee33118055 to your computer and use it in GitHub Desktop.
Save zoenolan/493a9c3c1dc505f987d3b5ee33118055 to your computer and use it in GitHub Desktop.
An OpenAPI 3.0 definition for GeoJSON with Geometry and Features.
# MIT License
#
# Copyright (c) 2017 Daniele Andreis <daniele.andreis@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
openapi: 3.0.0
info:
version: 1.0.0
title: GeoJSON geometry
description: An example of an OpenAPI definition for GeoJSON with Geometry and Features.
termsOfService: no
contact:
name: Zoe Nolan
email: github@zoenolan.org
url: "https://geojson.org/"
license:
name: GPLv3
url: https://www.gnu.org/licenses/gpl-3.0.html
externalDocs:
description: RFC7946 - The GeoJSON format.
url: https://tools.ietf.org/html/rfc7946
security:
- UserSecurity: []
paths:
/geometries:
get:
summary: GeoJSON geometry array
responses:
"200":
description: Successful response
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/GeometryCollection"
"400":
$ref: "#/components/responses/BadRequest400ErrorResponse"
"401":
$ref: "#/components/responses/Unauthorized401ErrorResponse"
"500":
$ref: "#/components/responses/Standard500ErrorResponse"
post:
summary: Create new geometry
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Geometry"
required: true
responses:
"201":
description: new geometry created
"400":
$ref: "#/components/responses/BadRequest400ErrorResponse"
"401":
$ref: "#/components/responses/Unauthorized401ErrorResponse"
"403":
$ref: "#/components/responses/Forbidden403ErrorResponse"
"500":
$ref: "#/components/responses/Standard500ErrorResponse"
servers:
- url: http://myHost/v1
components:
responses:
Standard500ErrorResponse:
description: An unexpected error occured.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
BadRequest400ErrorResponse:
description: The JSON is not valid
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
Unauthorized401ErrorResponse:
description: The request requires an user authentication
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
Forbidden403ErrorResponse:
description: the access is not allowed
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
securitySchemes:
UserSecurity:
type: http
scheme: basic
schemas:
Error:
required:
- code
- message
properties:
code:
type: string
message:
type: string
Geometry:
type: object
description: GeoJSon geometry
discriminator:
propertyName: type
required:
- type
externalDocs:
url: http://geojson.org/geojson-spec.html#geometry-objects
properties:
type:
type: string
enum:
- Point
- LineString
- Polygon
- MultiPoint
- MultiLineString
- MultiPolygon
description: the geometry type
Point3D:
type: array
description: Point in 3D space
externalDocs:
url: http://geojson.org/geojson-spec.html#id2
minItems: 2
maxItems: 3
items:
type: number
Point:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id2
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
$ref: "#/components/schemas/Point3D"
LineString:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id3
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
type: array
items:
$ref: "#/components/schemas/Point3D"
Polygon:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id4
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
$ref: "#/components/schemas/Point3D"
MultiPoint:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id5
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
type: array
items:
$ref: "#/components/schemas/Point3D"
MultiLineString:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id6
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
$ref: "#/components/schemas/Point3D"
MultiPolygon:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id6
allOf:
- $ref: "#/components/schemas/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
type: array
items:
$ref: "#/components/schemas/Point3D"
GeometryCollection:
type: object
description: GeoJSon geometry collection
required:
- type
- geometries
externalDocs:
url: http://geojson.org/geojson-spec.html#geometrycollection
properties:
type:
type: string
enum:
- GeometryCollection
geometries:
type: array
items:
$ref: "#/components/schemas/Geometry"
Feature:
type: object
description: GeoJSon Feature
required:
- type
- id
- geometry
externalDocs:
url: https://tools.ietf.org/html/rfc7946#section-3.2
properties:
type:
type: string
enum:
- Feature
id:
type: integer
geometry:
$ref: "#/components/schemas/GeometryCollection"
properties:
type: object
FeatureCollection:
type: object
description: GeoJSon Feature collection
required:
- type
- features
externalDocs:
url: https://tools.ietf.org/html/rfc7946#section-3.3
properties:
type:
type: string
enum:
- FeatureCollection
features:
type: array
items:
$ref: "#/components/schemas/Feature"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment