Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #13597
Closed
Open
Issue created Oct 05, 2022 by Administrator@rootContributor

[REQ] support follow redirects in swift libraries

Created by: Jonas1893

Is your feature request related to a problem? Please describe.

We have an API that uses ETags to implement a simple caching mechanism for large image data. We are requesting with the ETag of the locally cached image data in the request header and a response is either

  • 302 with a Location redirect header redirecting the client to the blob storage with an updated ETag in the response header
  • or 304 not modified, indicating that the locally cached data in the client (as indicated by the ETag) is not outdated and can still be used.

Currently two things are preventing this to work with the generator:

  1. The generated APIs for responses that define redirects will currently be generated with a Void return type. Both URLSession and Alamofire libraries currently already follow the redirect URL from the location header, however the data that is being retrieved is being discarded by always mapping to Void.
  2. Successful status code range is currently hardcoded for both URLSession and Alamofire implementations to 200..< 300. both 302 and 304 are treated as failure and the image data can not be returned to the caller

Describe the solution you'd like

For solving problem 1. I propose to change the return type to Data for redirect responses and pass the returned Data. This should probably sit behind a new generator flag to stay backwards compatible. For solving problem 2. I propose to add the configuration option for changing the successful status code range. This can also be useful for other use cases beyond the scope of follow redirects, that's I would propose to add this in a separate PR

Describe alternatives you've considered

I don't think there are many other options currently other than changing the API spec and directly returning image data instead of sending Location redirects headers. However for our project this is not possible

Additional context

Bildschirmfoto 2022-10-05 um 08 18 10
Assignee
Assign to
Time tracking