Skip to content

Conversation

@infantesimone
Copy link
Contributor

@infantesimone infantesimone commented Nov 2, 2022

Description

  • add response decoder generation for response with http status code 3xx, like this:
      /test-redirect-response-header:
        post:
          operationId: "testRedirectResponseHeader"
          responses:
            "302":
              description: "redirect to location"
              headers:
                Location:
                  type: string
            "500":
              description: "Fatal error"    

Motivation and Context

The purpose of this PR is to generate response decoders also for 3xx responses. Before this PR, trying to generate a ts client for this openapi we found the lack of a response decoder for the 302 with relative error.

How Has This Been Tested?

  • yarn test
  • yarn e2e

Screenshots (if appropriate):

Types of changes

  • Chore (improvement with no change in the behaviour)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@pagopa-github-bot
Copy link
Contributor

Warnings
⚠️

Please include a Pivotal story at the beginning of the PR title (see below).

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

Generated by 🚫 dangerJS

@infantesimone infantesimone marked this pull request as ready for review November 2, 2022 17:43
@infantesimone infantesimone requested a review from a team as a code owner November 2, 2022 17:43
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, prefer-arrow/prefer-arrow-functions
export function renderDecoderCode({ responses, operationId }: IOperationInfo) {
// use the first 2xx type as "success type" that we allow to be overridden
// use the first 2xx type and 3xx as "success type" that we allow to be overridden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to handle 3xx code as "succesful"?
We'll have a right path without a proper decoded object inside the response.

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

Successfully merging this pull request may close these issues.

3 participants