swagger-api / swagger-api/swagger-codegen

Stackoverflow exception occurs when using allOf in yaml (ver. 3.0.20)

Open
#10,354 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Ocures stackoverflow exception when trying to generate a client SDK from a yaml containing ofAll (the language is not important, I tried csharp and java).

This behavior is reproduced for versions 3.0.19, 3.0.20. An exception is visible only in verbose mode (i think is too not right).

For versions 3.0.18 and below, the behavior is different. In the output JSON (verbose log), a model class (with allOf) descriptions missing such properties as "datatype".

Swagger-codegen version

3.0.20, 3.0.19

Swagger declaration file content or url

This problem yaml example (test.yaml) :

openapi: 3.0.0
info:
  title: Test API
  description:
    Test allOf API
  version: 1.0.0
paths:
  /login:
    post:
      summary: >-
        Login procedure
      operationId: login
      x-data-view-operation:
        name: login
        caption: Login
      tags:
        - login
      parameters:
        - name: x-login
          in: header
          description: user login
          required: true
          schema:
            $ref: '#/components/schemas/TestClass'
      responses:
        '200':
          description: >-
            OK response.
components:
  schemas:
    TestClass:
      type: object
      properties:
        test1:
          allOf:
            - $ref: '#/components/schemas/Test1Type'
          x-override-datatype: "Test1Type"
          x-data-view-column:
            name: "Test1"
            type: "ColumnTypes.Number"
    Test1Type:
      type: string

-->

Command line used for generation

java^
-jar ".\swagger-codegen-cli-3.0.20.jar"^
generate^
-i "test.yaml"^
-l "csharp"^
-o ".\result"^
-v^

codegen.log

Steps to reproduce

For reproduce start generating with verbose.

Related issues/PRs
Suggest a fix/enhancement

I don’t understand what the matter is, I tried to use allOf in different ways. If there is an ollof in the yaml, an exception occurs.

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 by running swagger-codegen-cli-3.0.20.jar with test.yaml, the csharp generator, and verbose logging as shown. Compare behavior with 3.0.18 and below, checking where the allOf schema causes the stack overflow. Done means the example generates successfully without a stack overflow and the affected model properties retain their expected metadata.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.