Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declared result headers are ignored #179

Open
xperiandri opened this issue Jan 31, 2021 · 2 comments
Open

Declared result headers are ignored #179

xperiandri opened this issue Jan 31, 2021 · 2 comments

Comments

@xperiandri
Copy link
Contributor

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

@xperiandri
Copy link
Contributor Author

@sergey-tihon, please, point me where to apply fix I will code that today

@sergey-tihon
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants