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
c93be691
There was an error fetching the commit references. Please try again later.
Commit
c93be691
authored
1 year ago
by
Martin Slovík
Browse files
Options
Downloads
Patches
Plain Diff
Implementing CountryDto endpoints.
parent
a5660e04
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/CountryController.java
+81
-0
81 additions, 0 deletions
...in/java/cz/muni/fi/pa165/core/rest/CountryController.java
openapi.yaml
+126
-0
126 additions, 0 deletions
openapi.yaml
with
207 additions
and
0 deletions
core/src/main/java/cz/muni/fi/pa165/core/rest/CountryController.java
0 → 100644
+
81
−
0
View file @
c93be691
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
);
}
}
This diff is collapsed.
Click to expand it.
openapi.yaml
+
126
−
0
View file @
c93be691
...
@@ -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'
...
...
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