nirvana icon indicating copy to clipboard operation
nirvana copied to clipboard

How to insert introduction to generated api docs

Open wutz opened this issue 5 years ago • 10 comments

Is this a BUG REPORT or FEATURE REQUEST?:

/kind feature

What you expected to happen:

Before to use api, user need to known about general information, like how to Authentication.

wutz avatar Mar 20 '19 03:03 wutz

Write your description to nirvana.yaml.

kdada avatar Mar 20 '19 03:03 kdada

Write to description ? I may be write more than one paragraph.

wutz avatar Mar 20 '19 03:03 wutz

May be like https://docs.docker.com/engine/api/v1.25/ to provide multiple section, example: Errors, Versioning and Authentication.

wutz avatar Mar 20 '19 03:03 wutz

YAML supports multi-lines string:

description: |
  Write your description here.
  This is the second paragraph.

kdada avatar Mar 20 '19 06:03 kdada

/kind support

kdada avatar Mar 20 '19 06:03 kdada

I'm refer to https://github.com/Rebilly/ReDoc/blob/master/demo/swagger.yaml, but line start with # can not display as a heading, it just display as origin.

description: |
  The description here.
  # Introduction
  The introduction here.

image

wutz avatar Mar 21 '19 01:03 wutz

I have notice that the new line of description which in nirvana.yaml have been generated as \u003cbr/\u003e (<br/>).

If i change the new line of generated openapi spec json from <br/> to \n, then # introduction can display heading correctly.

wutz avatar Mar 21 '19 02:03 wutz

https://github.com/caicloud/nirvana/blob/e559644a421467a6d682b8d3cd056c974f9cee77/utils/generators/swagger/generator.go#L529-L531

@kdada Why replace \n to <br/> ?

wutz avatar Mar 21 '19 02:03 wutz

@wutzx

If not escape newline, two line will be merged into one line in markdown. It seems that we should not replace the newline character.

kdada avatar Mar 21 '19 03:03 kdada

/kind bug

kdada avatar Mar 21 '19 03:03 kdada