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

Implementing CountryDto endpoints.

parent a5660e04
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.CountryApi;
import cz.muni.fi.pa165.core.api.CountryApiDelegate;
import cz.muni.fi.pa165.core.model.CountryDto;
import cz.muni.fi.pa165.core.model.NewCountryDtoRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class CountryController implements CountryApiDelegate {
/**
* POST /api/countries : Create a new country.
* Creates a new country and returns it as a response.
*
* @param newCountryDtoRequest (required)
* @return Created (status code 201)
* or Input data not correct (status code 400)
* @see CountryApi#createCountry
*/
@Override
public ResponseEntity<CountryDto> createCountry(NewCountryDtoRequest newCountryDtoRequest) {
return CountryApiDelegate.super.createCountry(newCountryDtoRequest);
}
/**
* DELETE /api/countries/{id} : Delete country by id.
*
* @param id (required)
* @return Deleted (status code 204)
* or Not Found (status code 404)
* @see CountryApi#deleteCountry
*/
@Override
public ResponseEntity<Void> deleteCountry(Long id) {
return CountryApiDelegate.super.deleteCountry(id);
}
/**
* GET /api/countries : Get all countries.
* Returns an array of objects representing countries.
*
* @return OK (status code 200)
* @see CountryApi#getAllCountries
*/
@Override
public ResponseEntity<List<CountryDto>> getAllCountries() {
return CountryApiDelegate.super.getAllCountries();
}
/**
* GET /api/countries/{id} : Get country by id.
* Returns an object representing a country.
*
* @param id (required)
* @return OK (status code 200)
* @see CountryApi#getCountryById
*/
@Override
public ResponseEntity<CountryDto> getCountryById(Long id) {
return CountryApiDelegate.super.getCountryById(id);
}
/**
* PUT /api/countries/{id} : Update country by id.
* Updates a country by id and returns it as a response.
*
* @param id (required)
* @param countryDto (required)
* @return OK (status code 200)
* or Input data not correct (status code 400)
* @see CountryApi#updateCountry
*/
@Override
public ResponseEntity<CountryDto> updateCountry(Long id, CountryDto countryDto) {
return CountryApiDelegate.super.updateCountry(id, countryDto);
}
}
...@@ -708,6 +708,121 @@ paths: ...@@ -708,6 +708,121 @@ paths:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/ErrorMessage' $ref: '#/components/schemas/ErrorMessage'
/api/countries:
get:
tags:
- Country
summary: Get all countries.
description: Returns an array of objects representing countries.
operationId: getAllCountries
responses:
"200":
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/CountryDto'
post:
tags:
- Country
summary: Create a new country.
description: Creates a new country and returns it as a response.
operationId: createCountry
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NewCountryDtoRequest'
required: true
responses:
"201":
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/CountryDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
/api/countries/{id}:
get:
tags:
- Country
summary: Get country by id.
description: Returns an object representing a country.
operationId: getCountryById
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CountryDto'
delete:
tags:
- Country
summary: Delete country by id.
operationId: deleteCountry
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:
- Country
summary: Update country by id.
operationId: updateCountry
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
description: Updates a country by id and returns it as a response.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CountryDto'
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CountryDto'
"400":
description: Input data not correct
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorMessage'
components: components:
schemas: schemas:
DomainEntity: DomainEntity:
...@@ -982,6 +1097,17 @@ components: ...@@ -982,6 +1097,17 @@ components:
type: string type: string
description: country name description: country name
example: Canada example: Canada
NewCountryDtoRequest:
type: object
title: New Country Request
description: Object for requesting a new Country.
required:
- name
properties:
name:
type: string
description: country name
example: Canada
CityDto: CityDto:
allOf: allOf:
- $ref: '#/components/schemas/DomainEntity' - $ref: '#/components/schemas/DomainEntity'
......
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