Neoteroi / essentials-openapi

Functions to handle OpenAPI Documentation.
MIT License
21 stars 9 forks source link

Markdown missing a newline after simple response types #27

Closed kylewm closed 1 year ago

kylewm commented 1 year ago

When a response either has no content or is a reference to a response schema, the newline after it is getting stripped. Here's a small example:

openapi: 3.0.0
info:
  title: Test
  description: Demonstrate newline bug
  version: 0.0.0
paths:
  /cats:
    get:
      summary: Get a list of cats
      responses:
        "200":
          $ref: "#/components/responses/GetCatsResponse"
    post:
      summary: Create a new cat
      responses:
        "200":
          description: Success
    delete:
      summary: Delete a cat
      responses:
        "200":
          description: Success

components:
  responses:
    GetCatsResponse:
      description: List of cats

Renders markdown like this

❯ oad gen-docs -s openapi.yaml -d output.md --style MARKDOWN
...
### GET /cats
Get a list of cats

### Response 200 OK
Refer to the common response description: [GetCatsResponse](#getcatsresponse)### POST /cats
Create a new cat

### Response 200 OK### DELETE /cats
Delete a cat

### Response 200 OK
...

i.e., ### POST and ### DELETE are not on their own line.

Thanks for taking a look!

RobertoPrevato commented 1 year ago

Hi @kylewm Thank You for reporting this issue. I take a look - the good news is that it will be easy to fix. 😄 The Jinja templates in this project are quite complex, also because of the number of combinations that are possible with OpenAPI specification.

kylewm commented 1 year ago

That's great to hear, and thank you for the speedy response! I started taking a look at it myself, but quickly got overwhelmed by jinja's whitespace stripping behavior 😄 so wanted to at least capture the issue.

RobertoPrevato commented 1 year ago

Hi @kylewm This is now fixed, please upgrade with

pip install -U essentials-openapi

Once again, this took me much time because I am focused on my web framework these days.

With this release I also fixed another bug and made a bit of workflow maintenance (upgrading to pyproject.toml and Hatch build).