Skip to content
Snippets Groups Projects
Commit 68dd9fe4 authored by Martin Slovík's avatar Martin Slovík
Browse files

Implementing CityDto endpoints.

parent c93be691
No related branches found
No related tags found
No related merge requests found
package cz.muni.fi.pa165.core.rest;
import cz.muni.fi.pa165.core.api.CityApi;
import cz.muni.fi.pa165.core.api.CityApiDelegate;
import cz.muni.fi.pa165.core.model.CityDto;
import cz.muni.fi.pa165.core.model.NewCityDtoRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CityController implements CityApiDelegate {
/**
* POST /api/cities/{cityId}/countries/{countryId} : Assign country to a city.
*
* @param cityId (required)
* @param countryId (required)
* @return OK (status code 201)
* or Input data not correct (status code 400)
* @see CityApi#assignCountry
*/
@Override
public ResponseEntity<CityDto> assignCountry(Long cityId, Long countryId) {
return CityApiDelegate.super.assignCountry(cityId, countryId);
}
/**
* POST /api/cities : Create a new city.
* Creates a new city and returns it as a response.
*
* @param newCityDtoRequest (required)
* @return Created (status code 201)
* or Input data not correct (status code 400)
* @see CityApi#createCity
*/
@Override
public ResponseEntity<CityDto> createCity(NewCityDtoRequest newCityDtoRequest) {
return CityApiDelegate.super.createCity(newCityDtoRequest);
}
/**
* DELETE /api/cities/{id} : Delete city by id.
*
* @param id (required)
* @return Deleted (status code 204)
* or Not Found (status code 404)
* @see CityApi#deleteCity
*/
@Override
public ResponseEntity<Void> deleteCity(Long id) {
return CityApiDelegate.super.deleteCity(id);
}
/**
* DELETE /api/cities/{cityId}/countries/{countryId} : Delete assignment of country to a city.
*
* @param cityId (required)
* @param countryId (required)
* @return Deleted (status code 204)
* or Not Found (status code 404)
* @see CityApi#deleteCountryAssignment
*/
@Override
public ResponseEntity<Void> deleteCountryAssignment(Long cityId, Long countryId) {
return CityApiDelegate.super.deleteCountryAssignment(cityId, countryId);
}
/**
* GET /api/cities/{id} : Get city by id.
* Returns an object representing a city.
*
* @param id (required)
* @return OK (status code 200)
* @see CityApi#getCityById
*/
@Override
public ResponseEntity<CityDto> getCityById(Long id) {
return CityApiDelegate.super.getCityById(id);
}
/**
* PUT /api/cities/{id} : Update city by id.
* Updates a city by id and returns it as a response.
*
* @param id (required)
* @param cityDto (required)
* @return OK (status code 200)
* or Input data not correct (status code 400)
* @see CityApi#updateCity
*/
@Override
public ResponseEntity<CityDto> updateCity(Long id, CityDto cityDto) {
return CityApiDelegate.super.updateCity(id, cityDto);
}
/**
* PUT /api/cities/{cityId}/countries/{countryId} : Update assignment of country to a city.
*
* @param cityId (required)
* @param countryId (required)
* @return OK (status code 200)
* or Input data not correct (status code 400)
* @see CityApi#updateCountryAssignment
*/
@Override
public ResponseEntity<CityDto> updateCountryAssignment(Long cityId, Long countryId) {
return CityApiDelegate.super.updateCountryAssignment(cityId, countryId);
}
}
......@@ -823,6 +823,211 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/api/cities:
get:
tags:
- Country
summary: Get all cities.
description: Returns an array of objects representing cities.
operationId: getAllCities
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CityDto'
post:
tags:
- City
summary: Create a new city.
description: Creates a new city and returns it as a response.
operationId: createCity
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NewCityDtoRequest'
required: true
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/api/cities/{id}:
get:
tags:
- City
summary: Get city by id.
description: Returns an object representing a city.
operationId: getCityById
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
delete:
tags:
- City
summary: Delete city by id.
operationId: deleteCity
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"204":
description: Deleted
"404":
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
put:
tags:
- City
summary: Update city by id.
operationId: updateCity
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
description: Updates a city by id and returns it as a response.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/api/cities/{cityId}/countries/{countryId}:
post:
tags:
- City
summary: Assign country to a city.
operationId: assignCountry
parameters:
- name: cityId
in: path
required: true
schema:
type: integer
format: int64
- name: countryId
in: path
required: true
schema:
type: integer
format: int64
responses:
"201":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
put:
tags:
- City
summary: Update assignment of country to a city.
operationId: updateCountryAssignment
parameters:
- name: cityId
in: path
required: true
schema:
type: integer
format: int64
- name: countryId
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CityDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
delete:
tags:
- City
summary: Delete assignment of country to a city.
operationId: deleteCountryAssignment
parameters:
- name: cityId
in: path
required: true
schema:
type: integer
format: int64
- name: countryId
in: path
required: true
schema:
type: integer
format: int64
responses:
"204":
description: Deleted
"404":
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
components:
schemas:
DomainEntity:
......@@ -1121,13 +1326,24 @@ components:
name:
type: string
description: city name
example: New York, London
example: London
country:
$ref: '#/components/schemas/CountryDto'
airports:
type: array
items:
$ref: '#/components/schemas/AirplaneDto'
NewCityDtoRequest:
type: object
title: New City Request
description: Object for requesting a new City.
required:
- name
properties:
name:
type: string
description: city name
example: London
GPSLocationDto:
type: object
title: GPS Location
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment