Skip to content

Commit 35d4cb7

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

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
@@ -32,7 +32,7 @@ public CarbonAwareController(ILogger<CarbonAwareController> logger, IEmissionsAg
3232
/// </summary>
3333
/// <param name="parameters">The request object <see cref="EmissionsDataForLocationsParametersDTO"/></param>
3434
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
35-
[Produces("application/json")]
35+
[Produces("application/json", "application/json; charset=utf-8")]
3636
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
3737
[ProducesResponseType(StatusCodes.Status204NoContent)]
3838
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -51,7 +51,7 @@ public async Task<IActionResult> GetBestEmissionsDataForLocationsByTime([FromQue
5151
/// </summary>
5252
/// <param name="parameters">The request object <see cref="EmissionsDataForLocationsParametersDTO"/></param>
5353
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
54-
[Produces("application/json")]
54+
[Produces("application/json", "application/json; charset=utf-8")]
5555
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
5656
[ProducesResponseType(StatusCodes.Status204NoContent)]
5757
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -72,7 +72,7 @@ public async Task<IActionResult> GetEmissionsDataForLocationsByTime([FromQuery]
7272
/// <param name="time"> [Optional] Start time for the data query.</param>
7373
/// <param name="toTime"> [Optional] End time for the data query.</param>
7474
/// <returns>Array of EmissionsData objects that contains the location, time and the rating in g/kWh</returns>
75-
[Produces("application/json")]
75+
[Produces("application/json", "application/json; charset=utf-8")]
7676
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsData>))]
7777
[ProducesResponseType(StatusCodes.Status204NoContent)]
7878
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
@@ -111,7 +111,7 @@ public async Task<IActionResult> GetEmissionsDataForLocationByTime([FromQuery, S
111111
/// <response code="400">Returned if any of the input parameters are invalid</response>
112112
/// <response code="500">Internal server error</response>
113113
/// <response code="501">Returned if the underlying data source does not support forecasting</response>
114-
[Produces("application/json")]
114+
[Produces("application/json", "application/json; charset=utf-8")]
115115
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsForecastDTO>))]
116116
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
117117
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -145,7 +145,7 @@ public async Task<IActionResult> GetCurrentForecastData([FromQuery] EmissionsFor
145145
/// <response code="400">Returned if any of the input parameters are invalid</response>
146146
/// <response code="500">Internal server error</response>
147147
/// <response code="501">Returned if the underlying data source does not support forecasting</response>
148-
[Produces("application/json")]
148+
[Produces("application/json", "application/json; charset=utf-8")]
149149
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<EmissionsForecastDTO>))]
150150
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
151151
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -176,7 +176,7 @@ public async Task<IActionResult> BatchForecastDataAsync([FromBody] IEnumerable<E
176176
/// <response code="200">Returns a single object that contains the information about the request and the average marginal carbon intensity</response>
177177
/// <response code="400">Returned if any of the requested items are invalid</response>
178178
/// <response code="500">Internal server error</response>
179-
[Produces("application/json")]
179+
[Produces("application/json", "application/json; charset=utf-8")]
180180
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(CarbonIntensityDTO))]
181181
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
182182
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]
@@ -211,7 +211,7 @@ public async Task<IActionResult> GetAverageCarbonIntensity([FromQuery] CarbonInt
211211
/// <response code="200">Returns an array of objects where each contains location, time boundaries and the corresponding average marginal carbon intensity</response>
212212
/// <response code="400">Returned if any of the requested items are invalid</response>
213213
/// <response code="500">Internal server error</response>
214-
[Produces("application/json")]
214+
[Produces("application/json", "application/json; charset=utf-8")]
215215
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<CarbonIntensityDTO>))]
216216
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ValidationProblemDetails))]
217217
[ProducesResponseType(StatusCodes.Status500InternalServerError, Type = typeof(ValidationProblemDetails))]

0 commit comments

Comments
 (0)