Skip to content

Instantly share code, notes, and snippets.

@dostolu
Forked from bubbobne/geometry_geojson.yaml
Last active June 9, 2018 17: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 dostolu/60bc1c101634f4fcb870c9848457807a to your computer and use it in GitHub Desktop.
Save dostolu/60bc1c101634f4fcb870c9848457807a to your computer and use it in GitHub Desktop.
A swagger geojson geometry description
#MIT License
#
#Copyright (c) 2017 Daniele Andreis
#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.
swagger: '2.0'
info:
version: "1.0.0"
title: GeoJSON geometry
description: An example of swagger file for a geographic API. It contains the geometry definitions
termsOfService: "no"
contact:
name: Daniele Andreis
email: daniele.andreis@gmail.com
url: ""
license:
name: MIT
url: https://opensource.org/licenses/mit-license.php
externalDocs:
description: find more info here
url: http://geojson.org/geojson-spec.html#geometry-objects
schemes:
- http
host: myHost
basePath: /v1
consumes:
- "application/json"
produces:
- "application/json"
securityDefinitions:
UserSecurity:
type: basic
# AdminSecurity:
# type: basic
# MediaSecurity:
# type: basic
#globalmente e' userSecurity ma posso cambiare localmente
security:
- UserSecurity: []
paths:
/geometries:
get:
summary: GeoJSON geometry array
description:
responses:
200:
description: Successful response
schema:
type: array
items:
$ref: "#/definitions/Geometry<Collection"
400:
$ref: "#/responses/BadRequest400ErrorResponse"
401:
$ref: "#/responses/Unauthorized401ErrorResponse"
500:
$ref: "#/responses/Standard500ErrorResponse"
post:
summary: Create new geometry
description:
parameters:
- name: geom
in: body
required: true
schema:
$ref: "#/definitions/Geometry"
responses:
201:
description: new geometry created
400:
$ref: "#/responses/BadRequest400ErrorResponse"
401:
$ref: "#/responses/Unauthorized401ErrorResponse"
403:
$ref: "#/responses/Forbidden403ErrorResponse"
500:
$ref: "#/responses/Standard500ErrorResponse"
definitions:
Error:
required:
- code
- message
properties:
code:
type: string
message:
type: string
Geometry:
type: object
description: GeoJSon geometry
discriminator: 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
Point2D:
type: array
maxItems: 2
minItems: 2
items:
type: number
Point:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id2
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
$ref: '#/definitions/Point2D'
LineString:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id3
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
type: array
items:
$ref: '#/definitions/Point2D'
Polygon:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id4
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
$ref: '#/definitions/Point2D'
MultiPoint:
type: object
description: GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id5
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
type: array
items:
$ref: '#/definitions/Point2D'
MultiLineString:
type: object
description:GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id6
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
$ref: '#/definitions/Point2D'
MultiPolygon:
type: object
description:GeoJSon geometry
externalDocs:
url: http://geojson.org/geojson-spec.html#id6
allOf:
- $ref: "#/definitions/Geometry"
- properties:
coordinates:
type: array
items:
type: array
items:
type: array
items:
$ref: '#/definitions/Point2D'
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
description:
geometries:
type: array
items:
$ref: '#/definitions/Geometry'
responses:
Standard500ErrorResponse:
description: An unexpected error occured.
schema:
$ref: "#/definitions/Error"
BadRequest400ErrorResponse:
description: The JSON is not valid
schema:
$ref: "#/definitions/Error"
Unauthorized401ErrorResponse:
description: The request requires an user authentication
schema:
$ref: "#/definitions/Error"
Forbidden403ErrorResponse:
description: the access is not allowed
schema:
$ref: "#/definitions/Error"
# NotFound404ErrorResponse:
# description: not found check the path or the query
# schema:
# $ref: "#/definitions/Error"
# Ok200Response:
# description: Eyerything is working
# schema:
# $ref: "#/definitions/OK"
# Create201Response:
# description: New resource has been created
# schema:
# $ref: "#/definitions/OK"
# Delete204Response:
# description: The resource was successfully deleted
# schema:
# $ref: "#/definitions/OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment