OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Swift6] requiresAuthentication should be optional or enum with type of authorization

Open
#22,482 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

According to the OpenAPI documentation, it's possible to create a "path" with security options: without authorization + with authorization (the behavior of the "path" depends on this).
I encountered a similar need.

Describe the solution you'd like

  • Provide option requiresAuthentication as enum
enum RequiresAuthentication {
    case required
    case optional
    case nonRequired
}

for determine when we need to force check auth in interceptor or not.

  • May be we also need to provide types of auth for choose properly way of auth in interceptor

  • I suppose, also we need to improve algorithms in generator, because now it don't understand more then one auth variants

Describe alternatives you've considered

There is a hack solution, for example, looking at the method name in the interceptor and making a decision manually )))
But this is not code generation way :)

Additional context

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by tracing how the Swift6 generator handles requiresAuthentication, authentication interceptors, and multiple OpenAPI security variants; clarify the expected optional or enum behavior and supported authorization types. Done means generated clients correctly distinguish required, optional, and non-required authentication cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, swift
Domain
api, authentication, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.