Skip to content

Commit 8763289

Browse files
committed
WebAPI: Bugfix: Add 'application/json; charset=utf-8' to Produces annotations.
* Issue reference: Green-Software-Foundation#198 * Produces filters now accept application/json; charset=utf-8 Signed-off-by: Szymon Duchniewicz <[email protected]>
1 parent eb5e5a0 commit 8763289

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/CarbonAware.WebApi/src/Controllers/CarbonAwareController.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public CarbonAwareController(ILogger<CarbonAwareController> logger, IEmissionsHa
3434
/// </summary>
3535
/// <param name="parameters">The request object <see cref="EmissionsDataForLocationsParametersDTO"/></param>
3636
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
37-
[Produces("application/json")]
37+
[Produces("application/json", "application/json; charset=utf-8")]
3838
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
3939
[ProducesResponseType(StatusCodes.Status204NoContent)]
4040
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -50,7 +50,7 @@ public async Task<IActionResult> GetBestEmissionsDataForLocationsByTime([FromQue
5050
/// </summary>
5151
/// <param name="parameters">The request object <see cref="EmissionsDataForLocationsParametersDTO"/></param>
5252
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
53-
[Produces("application/json")]
53+
[Produces("application/json", "application/json; charset=utf-8")]
5454
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
5555
[ProducesResponseType(StatusCodes.Status204NoContent)]
5656
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -68,7 +68,7 @@ public async Task<IActionResult> GetEmissionsDataForLocationsByTime([FromQuery]
6868
/// <param name="startTime"> [Optional] Start time for the data query.</param>
6969
/// <param name="endTime"> [Optional] End time for the data query.</param>
7070
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
71-
[Produces("application/json")]
71+
[Produces("application/json", "application/json; charset=utf-8")]
7272
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
7373
[ProducesResponseType(StatusCodes.Status204NoContent)]
7474
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -107,7 +107,7 @@ public async Task<IActionResult> GetEmissionsDataForLocationByTime(
107107
/// <response code="400">Returned if any of the input parameters are invalid</response>
108108
/// <response code="500">Internal server error</response>
109109
/// <response code="501">Returned if the underlying data source does not support forecasting</response>
110-
[Produces("application/json")]
110+
[Produces("application/json", "application/json; charset=utf-8")]
111111
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsForecastDTO>))]
112112
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
113113
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -138,7 +138,7 @@ public async Task<IActionResult> GetCurrentForecastData([FromQuery] EmissionsFor
138138
/// <response code="400">Returned if any of the input parameters are invalid</response>
139139
/// <response code="500">Internal server error</response>
140140
/// <response code="501">Returned if the underlying data source does not support forecasting</response>
141-
[Produces("application/json")]
141+
[Produces("application/json", "application/json; charset=utf-8")]
142142
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsForecastDTO>))]
143143
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
144144
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -172,7 +172,7 @@ public async Task<IActionResult> BatchForecastDataAsync([FromBody] IEnumerable<E
172172
/// <response code="200">Returns a single object that contains the information about the request and the average marginal carbon intensity</response>
173173
/// <response code="400">Returned if any of the requested items are invalid</response>
174174
/// <response code="500">Internal server error</response>
175-
[Produces("application/json")]
175+
[Produces("application/json", "application/json; charset=utf-8")]
176176
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(CarbonIntensityDTO))]
177177
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
178178
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -209,7 +209,7 @@ public async Task<IActionResult> GetAverageCarbonIntensity([FromQuery] CarbonInt
209209
/// <response code="200">Returns an array of objects where each contains location, time boundaries and the corresponding average marginal carbon intensity</response>
210210
/// <response code="400">Returned if any of the requested items are invalid</response>
211211
/// <response code="500">Internal server error</response>
212-
[Produces("application/json")]
212+
[Produces("application/json", "application/json; charset=utf-8")]
213213
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<CarbonIntensityDTO>))]
214214
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
215215
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]

0 commit comments

Comments
 (0)