OpenAPITools / OpenAPITools/openapi-generator

[BUG] Confluence Wiki output doesn't work for array types

Open
#7,485 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report Checklist
  • [Y] Have you provided a full/minimal spec to reproduce the issue?
  • [Y] Have you validated the input using an OpenAPI validator (example)?
  • [Y] Have you tested with the latest master to confirm the issue still exists?
  • [Y] Have you searched for related issues/PRs?
  • [Y] What's the actual output vs expected output?
  • [N] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When the openAPI spec contains array types, the generator doesn't create proper Cwiki.

Example (incorrect) output:
...
|| Response Type | array[ErrorResult] |
|| Response Model | [array[ErrorResult] Model|#array[ErrorResult]ModelAnchor|Jump to model] |

It should be more like:
...
|| Response Type | array of ErrorResult |
|| Response Model | [ErrorResult Model|#ErrorResultModelAnchor|Jump to model] |

openapi-generator version

v4.3.1

OpenAPI declaration file content or url
{
  "openapi": "3.0.1",
  "info": { "title": "foo", "version": "1.0.0" },
  "servers": [ { "url": "https://foo.com/bar" } ],
  "paths": {
    "/foo": {
      "get": {
        "summary": "baz",
        "operationId": "getBaz",
        "responses": { "404": { "description": "Requested resource was not found", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ArrayOfErrorResult" } } } } }
      }
    }
  },
  "components": {  "schemas": {
      "ErrorResult": { "type": "object", "properties": { "message": {
            "type": "string",
            "description": "Additional details about error encountered"
          },
          "code": { "type": "integer", "description": "Error code", "format": "int32" }  },
        "description": "Contains error details of request"
      },
      "ArrayOfErrorResult": { "type": "array", "items": { "$ref": "#/components/schemas/ErrorResult"       } } } } }
Generation Details

openapi-generator generate -i example.json -g cwiki

Related issues/PRs

Didn't see any

Suggest a fix

The mustache file looks correct, but it's using a field ({{{dataType}}} that puts in the square brackets, confusing Confluence. Simple escaping doesn't seem to work.

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 cwiki generator's Mustache template and run the reported openapi-generator command against the supplied declaration. Compare how array response types populate dataType and the generated Confluence links. Done means array responses render as “array of ErrorResult” and link to the ErrorResult model without array brackets in the anchor.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.