OpenAPITools / OpenAPITools/openapi-generator

[BUG][Java][Client][Native] Java 11 native client generator doesn't support security and securitySchemes

Open
#6,742 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

The Java 11 Native HTTP client generator (native) doesn't support security and securitySchemes as described in https://swagger.io/docs/specification/authentication/ and https://swagger.io/specification/#security-scheme-object.

openapi-generator version

openapi-generator-cli 4.3.1

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Title
  version: 1.0.0
  description: Description
paths:
  /something:
    get:
      # Operation-specific security:
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: OK (successfully authenticated)
# https://swagger.io/docs/specification/authentication/api-keys/
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
security:
  - ApiKeyAuth: []
Command line used for generation
# wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar -O openapi-generator-cli.jar
# java -jar openapi-generator-cli.jar generate -i openapi.yaml -g java -o pkg/instana/openapi --skip-validate-spec -p dateLibrary=java8 --library native
Steps to reproduce

Use the OpenAPI spec from above and the command line mentioned above to generate the client.

No ApiKeyAuth class or any class related to authentication at all is being generated.

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

Start with the OpenAPI YAML example and run the listed openapi-generator-cli command using the Java native client generator. Inspect the generated client for handling of the operation and global security settings, then compare the output with the documented security and securitySchemes requirements. Done means the native client generates authentication support for the provided ApiKeyAuth example.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.