Fixed preorder api results; added CORS headers for docs
This commit is contained in:
@@ -12,7 +12,7 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
protected function findCity() {
|
||||
$search = $this->db()->escape($this->post['search']);
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
@@ -25,12 +25,12 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
$cities[] = $result->name;
|
||||
}
|
||||
|
||||
$citiesv= array_unique($cities);
|
||||
return mfResponse::Ok(['cities' => $cities]);
|
||||
$cities = array_unique($cities);
|
||||
return mfResponse::Ok(['cities' => array_values($cities)]);
|
||||
}
|
||||
|
||||
protected function findZip() {
|
||||
$search = $this->db()->escape($this->post['search']);
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
@@ -44,11 +44,11 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$zips = array_unique($zips);
|
||||
return mfResponse::Ok(['zips' => $zips]);
|
||||
return mfResponse::Ok(['zips' => array_values($zips)]);
|
||||
}
|
||||
|
||||
protected function findStreet() {
|
||||
$search = $this->db()->escape($this->post['search']);
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
@@ -62,14 +62,14 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
$streets = array_unique($streets);
|
||||
return mfResponse::Ok(['streets' => $streets]);
|
||||
return mfResponse::Ok(['streets' => array_values($streets)]);
|
||||
}
|
||||
|
||||
protected function find() {
|
||||
$search_street = $this->db()->escape($this->post['street']);
|
||||
$search_zip = $this->db()->escape($this->post['zip']);
|
||||
$search_city = $this->db()->escape($this->post['city']);
|
||||
$search_housenumber = $this->db()->escape($this->post['housenumber']);
|
||||
$search_street = $this->db()->escape(trim($this->post['street']));
|
||||
$search_zip = $this->db()->escape(trim($this->post['zip']));
|
||||
$search_city = $this->db()->escape(trim($this->post['city']));
|
||||
$search_housenumber = $this->db()->escape(trim($this->post['housenumber']));
|
||||
|
||||
|
||||
if(!$search_street) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
SetEnvIf Origin "(https://docs.breitband-steiermark.at|https://editor.swagger.io)$" AccessControlAllowOrigin=$0
|
||||
SetEnvIf Origin "(https://docs.thetool.xinon.at|https://editor.swagger.io)$" AccessControlAllowOrigin=$0
|
||||
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
|
||||
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS"
|
||||
Header add Access-Control-Allow-Headers: "X-Api-Key"
|
||||
|
||||
240
public/docs/preorder-api.yaml
Normal file
240
public/docs/preorder-api.yaml
Normal file
@@ -0,0 +1,240 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: thetool Preorder API
|
||||
description: API Dokumentation für thetool Vorbestellung
|
||||
contact:
|
||||
name: thetool Development Team
|
||||
email: thetool-api-support@xinon.at
|
||||
license:
|
||||
name: Apache 2.0 License
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: https://thetool.xinon.at/api/v1
|
||||
tags:
|
||||
- name: addressdb
|
||||
description: Abfrage von GWR Daten
|
||||
paths:
|
||||
/addressdb/findAddress:
|
||||
post:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Adressen suchen
|
||||
description: Sucht nach Adressen
|
||||
operationId: findAddresses
|
||||
requestBody:
|
||||
description: addressSearchRequest object. Parameter müssen mindestens 3 Zeichen lang sein, `zip` muss mindestens 2 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Address'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/Address'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status string
|
||||
example: OK
|
||||
result:
|
||||
type: object
|
||||
properties:
|
||||
addresses:
|
||||
$ref: '#/components/schemas/Addresses'
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findStreet:
|
||||
post:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Straßen suchen
|
||||
description: Sucht nach Straßen
|
||||
operationId: findStreets
|
||||
requestBody:
|
||||
description: addressComponentSearchRequest object. Parameter `search` muss mindestens 3 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status string
|
||||
example: OK
|
||||
result:
|
||||
type: object
|
||||
properties:
|
||||
streets:
|
||||
$ref: '#/components/schemas/Streets'
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findZip:
|
||||
post:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Postleitzahlen suchen
|
||||
description: Sucht nach Postleitzahlen
|
||||
operationId: findZips
|
||||
requestBody:
|
||||
description: zipSearchRequest object. Parameter `search` muss mindestens 2 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/zipComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/zipComponentSearchRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status string
|
||||
example: OK
|
||||
result:
|
||||
type: object
|
||||
properties:
|
||||
streets:
|
||||
$ref: '#/components/schemas/Zips'
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
/addressdb/findCity:
|
||||
post:
|
||||
tags:
|
||||
- addressdb
|
||||
summary: Ortschaften suchen
|
||||
description: Sucht nach Ortschaften
|
||||
operationId: findCity
|
||||
requestBody:
|
||||
description: addressComponentSearchRequest object. Parameter `search` muss mindestens 3 Zeichen lang sein.
|
||||
required: true
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
'application/x-www-form-urlencoded':
|
||||
schema:
|
||||
$ref: '#/components/schemas/addressComponentSearchRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
description: Status string
|
||||
example: OK
|
||||
result:
|
||||
type: object
|
||||
properties:
|
||||
streets:
|
||||
$ref: '#/components/schemas/Cities'
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
|
||||
Parameter missing or malformed
|
||||
'401':
|
||||
description: Unauthorized
|
||||
components:
|
||||
schemas:
|
||||
addressComponentSearchRequest:
|
||||
type: object
|
||||
properties:
|
||||
search:
|
||||
type: string
|
||||
description: Suchbegriff von mindestens 3 Zeichen Länge
|
||||
minLength: 3
|
||||
zipComponentSearchRequest:
|
||||
type: object
|
||||
properties:
|
||||
search:
|
||||
type: string
|
||||
description: Suchbegriff von mindestens 2 Zeichen Länge
|
||||
minLength: 2
|
||||
Zips:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
Cities:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
Streets:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
Addresses:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Address'
|
||||
Address:
|
||||
type: object
|
||||
properties:
|
||||
street:
|
||||
type: string
|
||||
description: Straße
|
||||
housenumber:
|
||||
type: string
|
||||
description: Hausnummer
|
||||
zip:
|
||||
type: string
|
||||
description: PLZ
|
||||
city:
|
||||
type: string
|
||||
description: Ortschaft
|
||||
securitySchemes:
|
||||
api_key_header:
|
||||
type: apiKey
|
||||
name: X-Api-Key
|
||||
in: header
|
||||
api_key_query:
|
||||
type: apiKey
|
||||
name: apikey
|
||||
in: query
|
||||
security:
|
||||
- api_key_header: []
|
||||
- api_key_query: []
|
||||
Reference in New Issue
Block a user