OpenAPITools / OpenAPITools/openapi-generator

[BUG] Java client generator does not support allOf with simple types

Open
#3,169 0 comments 0 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

Versions

openapi version 3.0.2
enerator version 4.0.0

Description

The java generator generates code that does not compile despite the openapi definition being valid and correctly interpreted by the swagger eidtor.

openapi: 3.0.2
info:
  title: Test API
  description: test
  version: 1.0.0
paths: {}
components:
  schemas:
    AlphaType:
      type: string
    Alpha_2:
      allOf:
        - $ref: '#/components/schemas/AlphaType'
        - minLength: 2
          maxLength: 2
          pattern: '[a-zA-Z]{2}'
    MyObject:
      type: object
      properties:
        blabla:
          $ref: '#/components/schemas/Alpha_2'
Steps to reproduce

Use swagger editor online and generate java client

Suggest a fix

The Alpha_2 should be transformed to the String class and the necessary jsr303 annotations should be added on the field.

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

Use the supplied OpenAPI 3.0.2 YAML with generator 4.0.0 to reproduce the Java client, then inspect the generated Alpha_2 and MyObject code. Done means the generated client compiles, Alpha_2 is represented as String, and the minLength, maxLength, and pattern constraints produce the needed JSR-303 annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
backend-api-design, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.