SwaggerProvider
SwaggerProvider copied to clipboard
Declared result headers are ignored
Description
/order:
post:
summary: Создает заказ-наряд
operationId: CreateOrder
requestBody:
$ref: '#/components/requestBodies/CarCodeBody'
responses:
'201':
description: Заказ успешно создан
headers:
Location:
schema:
$ref: '#/components/schemas/OrderId'
description: Уникальный идентификатор заказа
'404':
description: Код клиента или машина не найдены
Expected behavior
A resulting model exposes a Headers
property with all returned headers
Actual behavior
No way to get headers
Related information
1.0.0-Beta1
@sergey-tihon, please, point me where to apply fix I will code that today
A resulting model exposes a Headers property with all returned headers
I do not think that we should mess up all models with Header
properties. We need to correctly identity the location of the response from server (body or header) and correctly deserialize response from there.
Current implementation of OpenApiClientProvider support only Json responses.
Here we infer response type based on the response code 200/201 and inter result type https://github.com/fsprojects/SwaggerProvider/blob/net5/src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs#L135-L153
Here (assuming that response is always json format and in the body) we deserialize response into expected type https://github.com/fsprojects/SwaggerProvider/blob/net5/src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs#L302-L303
using ProvidedApiClientBase
If you plan to fix this, we need:
- [ ] Add endpoint to Swashbuckle.WebApi.Server that generates similar schema (response in the header with 201 status code)
- [ ] Decide how we will deserialize type from header string to assume that header is formatted as json object.
- [ ] Ensure that fix is implemented for both TPs (Swagger and OpenApi)