swagger-api / swagger-api/swagger-codegen

swagger-codegen -l html2 would be much nicer looking if it treated inheritance as in programming language doc generators

Open
#5,166 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: HTML General: Suggestion help wanted
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

swagger-codegen -l html2 would be much nicer looking if it treated inheritance as in programming language doc generators

Swagger declaration file content or url
swagger: '2.0'

info:
  title: "sscce"
  version: '1.0'
  description: sscce

definitions:

  Animal:
    type: object
    properties:
      number_of_legs:
        type: integer

  Pet:
    allOf:
      - $ref: "#/definitions/Animal"
      - type: object
        properties:
          name:
            type: string

  Cat:
    allOf:
    - $ref: "#/definitions/Pet"
    - type: object
      properties:
        likes_water:
          type: boolean


paths:
  /foo:
    post:
      parameters:
        - name: cat
          in: body
          schema: {$ref: "#/definitions/Cat"}
      responses:
        "200":
          description: foo
          type: string
Swagger-codegen version

current master; HEAD = 1c160df33897898da1c39f230c737eb6a313e6ba

Command line used for generation

JAR=".../swagger-codegen.git/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
java -jar "${JAR}" generate -i ~/sscce.yaml -l html2 -o foo

Renders as:

actual

which would be much nicer as

desired

The pic is not that descriptive but I assume you know what you are looking at since swagger-codegen is written in java.

My first issue is with the indenting which by the shape of it looks more like composition and second is with the copy-paste use of allOf which will not be obvious to a person unfamiliar with the OpenAPI spec format itself.

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

Reproduce the html2 generation command with the supplied Swagger YAML and compare the actual and desired renders. Start at the html2 generator and its templates, then define how the Animal, Pet, and Cat inheritance hierarchy should be shown; done means inheritance is presented as a hierarchy rather than repeated allOf content.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.