Skip to content

Commit 1d0d1ef

Browse files
committed
Fixning the Quality Gate errors
1 parent 1f311ee commit 1d0d1ef

4 files changed

Lines changed: 25 additions & 56 deletions

File tree

sample/CountryData.Sample.Console/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using CountryData.Standard;
1+

2+
using CountryData.Standard;
23

34
/// <summary>
45
/// Main program class for demonstrating the use of the CountryData library.
@@ -13,7 +14,7 @@ class Program
1314
/// <summary>
1415
/// Entry point of the program.
1516
/// </summary>
16-
static void Main()
17+
public static void Main()
1718
{
1819
GetCountries();
1920
GetCountryByCode("US");
@@ -111,7 +112,7 @@ static void GetCountryByPhoneCode(string phoneCode)
111112
Console.WriteLine($"Countries for phone code {phoneCode}:");
112113
foreach (var country in countries)
113114
{
114-
Console.WriteLine(country.CountryName);
115+
Console.WriteLine(country.CountryName);
115116
}
116117
}
117118

sample/CountryData.Sample.Web.API/Controllers/CountryController.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public CountryController(CountryHelper helper)
2323
/// </summary>
2424
/// <returns>A list of all countries. If no countries are found, a NotFound result is returned.</returns>
2525
[HttpGet]
26+
[ProducesResponseType(typeof(IEnumerable<Country>), 200)]
27+
[ProducesResponseType(404)]
2628
public IActionResult GetCountries()
2729
{
2830
var countries = _helper.GetCountries();
@@ -41,6 +43,8 @@ public IActionResult GetCountries()
4143
/// <param name="countryCode">The ISO country code.</param>
4244
/// <returns>The data for the specified country. If no data is found, a NotFound result is returned.</returns>
4345
[HttpGet("country")]
46+
[ProducesResponseType(typeof(Country), 200)]
47+
[ProducesResponseType(404)]
4448
public IActionResult GetCountryByCode([FromQuery] string countryCode)
4549
{
4650
var country = _helper.GetCountryByCode(countryCode);
@@ -52,8 +56,6 @@ public IActionResult GetCountryByCode([FromQuery] string countryCode)
5256
}
5357

5458

55-
56-
5759
/// <summary>
5860
/// Returns comprehensive data for all countries.
5961
/// </summary>
@@ -62,6 +64,8 @@ public IActionResult GetCountryByCode([FromQuery] string countryCode)
6264
/// If no data is found, a NotFound result is
6365

6466
[HttpGet("countries")]
67+
[ProducesResponseType(typeof(IEnumerable<Country>), 200)]
68+
[ProducesResponseType(404)]
6569
public IActionResult GetCountryData()
6670
{
6771
var country = _helper.GetCountryData();
@@ -70,16 +74,18 @@ public IActionResult GetCountryData()
7074
return NotFound();
7175
}
7276
return Ok(country);
73-
7477
}
7578

7679

80+
7781
/// <summary>
7882
/// Retrieves the regions for a given country code.
7983
/// </summary>
8084
/// <param name="countryCode">The ISO country code.</param>
8185
/// <returns>A list of regions for the specified country. If no regions are found, a NotFound result is returned.</returns>
8286
[HttpGet("regions")]
87+
[ProducesResponseType(typeof(IEnumerable<Regions>), 200)]
88+
[ProducesResponseType(404)]
8389
public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
8490
{
8591
var regions = _helper.GetRegionByCountryCode(countryCode);
@@ -91,21 +97,21 @@ public IActionResult GetRegionsByCountryCode([FromQuery] string countryCode)
9197
}
9298

9399

94-
95100
/// <summary>
96101
/// Retrieves the emoji flag for a given country short code.
97102
/// </summary>
98103
/// <param name="shortCode">The short code of the country.</param>
99104
/// <returns>The emoji flag for the specified country. If no flag is found, a NotFound result is returned.</returns>
100105
[HttpGet("flag")]
101-
public IActionResult GetCountryFlag([FromQuery] string shortCode)
106+
[ProducesResponseType(typeof(string), 200)]
107+
[ProducesResponseType(404)]
108+
public IActionResult GetCountryFlag([FromQuery] string countryCode)
102109
{
103-
var flag = _helper.GetCountryEmojiFlag(shortCode);
110+
var flag = _helper.GetCountryEmojiFlag(countryCode);
104111
if (flag == null)
105112
{
106113
return NotFound();
107114
}
108-
109115
return Ok(flag);
110116
}
111117

@@ -116,14 +122,15 @@ public IActionResult GetCountryFlag([FromQuery] string shortCode)
116122
/// <param name="shortCode">The short code of the country.</param>
117123
/// <returns>The phone code for the specified country. If no phone code is found, a NotFound result is returned.</returns>
118124
[HttpGet("phoneCodeByShortCode")]
119-
public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string shortCode)
125+
[ProducesResponseType(typeof(string), 200)]
126+
[ProducesResponseType(404)]
127+
public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string countryCode)
120128
{
121-
var phoneCode = _helper.GetPhoneCodeByCountryShortCode(shortCode);
129+
var phoneCode = _helper.GetPhoneCodeByCountryShortCode(countryCode);
122130
if (phoneCode == null)
123131
{
124132
return NotFound();
125133
}
126-
127134
return Ok(phoneCode);
128135
}
129136

@@ -133,14 +140,15 @@ public IActionResult GetPhoneCodeByCountryShortCode([FromQuery] string shortCode
133140
/// <param name="phoneCode">The phone code of the country.</param>
134141
/// <returns>The data for the specified country. If no data is found, a NotFound result is returned.</returns>
135142
[HttpGet("countryByPhoneCode")]
143+
[ProducesResponseType(typeof(Country), 200)]
144+
[ProducesResponseType(404)]
136145
public IActionResult GetCountryByPhoneCode([FromQuery] string phoneCode)
137146
{
138147
var countryDataByPhoneCode = _helper.GetCountriesByPhoneCode(phoneCode);
139148
if (countryDataByPhoneCode == null)
140149
{
141150
return NotFound();
142151
}
143-
144152
return Ok(countryDataByPhoneCode);
145153
}
146154

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +0,0 @@
1-
@CountryInforAPI_HostAddress = http://localhost:5016
2-
3-
# Retrieves the default country information
4-
GET {{CountryInforAPI_HostAddress}}/Country
5-
Accept: application/json
6-
7-
###
8-
9-
# Retrieves a list of all countries
10-
GET {{CountryInforAPI_HostAddress}}/Country/countries
11-
Accept: application/json
12-
13-
###
14-
15-
# Retrieves the regions for the country with the code 'US'
16-
GET {{CountryInforAPI_HostAddress}}/Country/US/regions
17-
Accept: application/json
18-
19-
###
20-
21-
# Retrieves the country information for the country with the code 'GH'
22-
GET {{CountryInforAPI_HostAddress}}/Country/GH/countries
23-
Accept: application/json
24-
25-
###
26-
27-
# Retrieves the emoji flag for the country with the code 'US'
28-
GET {{CountryInforAPI_HostAddress}}/Country/US/flag
29-
Accept: application/json
30-
31-
###
32-
# Retrieves the phone code for the country with the code 'US'
33-
GET {{CountryInforAPI_HostAddress}}/Country/GH/phoneCode
34-
Accept: application/json
35-
36-
###
37-
# Retrieves the country information for the country with the phone code '1'
38-
GET {{CountryInforAPI_HostAddress}}/Country/phoneCode/+233
39-
Accept: application/json
40-
41-
###

src/CountryData.Standard/CountryData.Standard.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<Version>1.4.0</Version>
1212
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1313
<PackageLicenseExpression>MIT</PackageLicenseExpression>
14-
<PackageReadmeFile>readme.md</PackageReadmeFile>
1514
<ReleaseNotes>Added new functionality to get country phone codes</ReleaseNotes>
1615
</PropertyGroup>
1716

@@ -25,6 +24,8 @@
2524
</EmbeddedResource>
2625
</ItemGroup>
2726

27+
28+
2829
<ItemGroup>
2930
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
3031
</ItemGroup>

0 commit comments

Comments
 (0)