Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate API documentation for Kubernetes using Swagger #9097

Closed
smarterclayton opened this issue Jun 2, 2015 · 24 comments
Closed

Generate API documentation for Kubernetes using Swagger #9097

smarterclayton opened this issue Jun 2, 2015 · 24 comments
Labels
area/swagger kind/documentation Categorizes issue or PR as related to documentation. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@smarterclayton
Copy link
Contributor

I'm in the process of generating AsciiDoc / Markdown from swagger specs. General goals:

  1. Generate documentation files suitable for inclusion into formal docs (OpenShift uses AsciiDoc -> DocBook)
  2. Generate tables and examples for all objects that correctly represent the action
  3. Have richer descriptions for each object and operation than we currently include, so that users understand what the object does (not just its fields).

Primary angle of attack is https://github.com/RobWin/swagger2markup

Issues encountered

  • swagger-parser doesn't handle the "TRACE" verb - going to open a pull to fix that
  • PATCH documents don't properly document their body parameter model type (no schema) - should be "any" which we can probably make happen with map[string]interface{}. Also, the return type should be versionedObject
  • We don't have descriptions on our path parameters for individual types, so any descriptions have to be external (swagger2markup supports external descriptions but this should come from the type).
  • Our top level API objects don't have title or description (description really needs to be a long description - it's the description of the API)
  • Our model objects don't have descriptions
  • Our operations don't have descriptions
  • go-restful ApiDeclaration doesn't have "Info" which contains title and description, used by the generator to frame the document
  • Our paths should have descriptions like "Use this path to operate on lists of Pods", "Use this path to operate on individual Pods", "Use this path to control the status of a Pod"
  • Our operation descriptions should be capitalized - those are used as headers and TOC lines in doc
  • Our dates and times are missing format "date-time"
  • runtime.RawExtension should be documented more like "any" - RawJSON is not actually exposed. May need to set JSON struct tags on it.
  • Swagger model order is random because ApiDeclarations.Models is a map[string]Object. We need to convert it to a []... in the swagger serialization format.
@smarterclayton smarterclayton added kind/documentation Categorizes issue or PR as related to documentation. area/upward-api area/usability labels Jun 2, 2015
@smarterclayton smarterclayton self-assigned this Jun 2, 2015
@smarterclayton
Copy link
Contributor Author

We don't set util.Time to date-time... intentional?

@smarterclayton
Copy link
Contributor Author

Swagger 1.2 and 2.0 don't support TRACE - OAI/OpenAPI-Specification#325

@bgrant0607 bgrant0607 added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Jun 2, 2015
@bgrant0607 bgrant0607 added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Jun 2, 2015
@bgrant0607 bgrant0607 added this to the v1.0-candidate milestone Jun 2, 2015
@smarterclayton
Copy link
Contributor Author

Will have an example of the output shortly so you can see what it looks like.

@RichieEscarez
Copy link
Contributor

Yes this would be great (@MikeJeffrey and I recently discussed the need for this)!

@goltermann goltermann modified the milestones: v1.0, v1.0-candidate Jun 2, 2015
@smarterclayton
Copy link
Contributor Author

@smarterclayton
Copy link
Contributor Author

swagger2markup can also inline descriptions - that was used to get http://docs.openshift.org/latest/rest_api/kubernetes_v1.html#v1-persistentvolumeclaim

@bgrant0607
Copy link
Member

Cool. Inlined from where?

@smarterclayton
Copy link
Contributor Author

Directory structure - the generator looks for a file in a directory that corresponds to the name of the object or the name of the topic. It slurps in the asciidoc file and then generates the rest of the structure.

On Jun 3, 2015, at 1:15 AM, Brian Grant notifications@github.com wrote:

Cool. Inlined from where?


Reply to this email directly or view it on GitHub.

@RichieEscarez
Copy link
Contributor

@smarterclayton does Markdown get automatically generated too (along with the AsciiDoc you use)? Im working on moving our user doc into GitHub pages and would like a copy of the API in Markdown.

@smarterclayton
Copy link
Contributor Author

swagger2markup can output to Markdown. Asciidoc is the default.

----- Original Message -----

@smarterclayton does Markdown get automatically generated too (along with the
AsciiDoc you use)? Im working on moving our user doc into GitHub pages and
would like a copy of the API in Markdown.


Reply to this email directly or view it on GitHub:
#9097 (comment)

@bgrant0607 bgrant0607 modified the milestones: v1.0-post, v1.0 Jul 6, 2015
@bgrant0607
Copy link
Member

Any progress on this?

@smarterclayton
Copy link
Contributor Author

Will open a pull next week when I get back from PTO

@bgrant0607
Copy link
Member

@andronat pointed out Slate on #11253

@bgrant0607
Copy link
Member

We're doing this now.

@caesarxuchao @nikhiljindal @RichieEscarez Anything we should fork off this issue before closing?

@caesarxuchao
Copy link
Member

I don't have more issues.

@RichieEscarez
Copy link
Contributor

I think the inconsistency between the GitHub repo and the Kubernetes.io versions of the API should be resolved.

Issue:
Today, out on Kubernetes.io, we override all the embedded CSS that is included with the current versions of these html formatted API files in order for it to display with the same color and font as our other docs.

From in the Github repo, the raw versions of these API files get inconsistently displayed in a different color.

Aside from the color and font differences between our two sources, the header in both files is also different (path vs. operations).

Possible solutions:

  • output to markdown instead (convert it to HTML for the kubernetes site like all other docs)
  • output html files with Kubernetes specific CSS (same color and font as our site)

@caesarxuchao
Copy link
Member

I think the inconsistency between the GitHub repo and the Kubernetes.io versions of the API should be resolved.

I don't know if this is necessary, they are two different websites, people won't expect the format to be the same.

Aside from the color and font differences between our two sources, the header in both files is also different (path vs. operations).

Good catch, this could be fixed by adding a line in https://github.com/kubernetes/kubernetes/blob/master/hack/gen-swagger-doc/gen-swagger-docs.sh and update the container image. Sorry I don't have time to do that this week.

[update]
this is fixed.

@bgrant0607
Copy link
Member

@nikhiljindal We should fork another issue to track all of the swagger problems.

@RichieEscarez
Copy link
Contributor

Re:
... the header in both files is also different (path vs. operations).

@caesarxuchao fixed the page title mismatch in #15040

@RichieEscarez
Copy link
Contributor

There is also: #15343

@bgrant0607
Copy link
Member

What's left to do here?

@caesarxuchao
Copy link
Member

There are no big problems, but several enhancements nice to have. The left issues from smarterclayton's first comment

  • Swagger model order is random because ApiDeclarations.Models is a map[string]Object. We need to convert it to a []... in the swagger serialization format.
  • Our operation descriptions should be capitalized - those are used as headers and TOC lines in doc
  • Our paths should have descriptions like "Use this path to operate on lists of Pods", "Use this path to operate on individual Pods", "Use this path to control the status of a Pod"
  • PATCH documents don't properly document their body parameter model type (no schema) - should be "any" which we can probably make happen with map[string]interface{}. (see if http://kubernetes.io/v1.1/docs/api-reference/v1/definitions.html#_unversioned_patch is good enough?)

@smarterclayton
Copy link
Contributor Author

This was done by many people.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swagger kind/documentation Categorizes issue or PR as related to documentation. priority/backlog Higher priority than priority/awaiting-more-evidence. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

5 participants