Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PA165 - Airport - project
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ján Macháček
PA165 - Airport - project
Commits
68dd9fe4
There was an error fetching the commit references. Please try again later.
Commit
68dd9fe4
authored
1 year ago
by
Martin Slovík
Browse files
Options
Downloads
Patches
Plain Diff
Implementing CityDto endpoints.
parent
c93be691
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/src/main/java/cz/muni/fi/pa165/core/rest/CityController.java
+109
-0
109 additions, 0 deletions
.../main/java/cz/muni/fi/pa165/core/rest/CityController.java
openapi.yaml
+217
-1
217 additions, 1 deletion
openapi.yaml
with
326 additions
and
1 deletion
core/src/main/java/cz/muni/fi/pa165/core/rest/CityController.java
0 → 100644
+
109
−
0
View file @
68dd9fe4
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
);
}
}
This diff is collapsed.
Click to expand it.
openapi.yaml
+
217
−
1
View file @
68dd9fe4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment