-
Notifications
You must be signed in to change notification settings - Fork 47
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
OpenAPI documentation for microservices #340
Comments
Review feedback on the draft doc published at https://draft-openlibertyio.mybluemix.net/docs/ref/general/#mp-openapi.html Good start. In general, while being technically accurate, it needs filling out a bit to make it easier to read and understand the points being made. The topic (as all the topics in the docs) needs to take an "inverted pyramid" approach to presenting information (https://en.wikipedia.org/wiki/Inverted_pyramid_(journalism)). Primarily, as the Wikipedia article says: "readers can leave the story at any point and understand it, even if they do not have all the details.". Provide the most important information (to the developer reading it) first, then less important details later - only a reader who's interested will read on but all readers will get what they need from the topic. Introductory section In the introductory section, the second paragraph needs to summarise what the "multiple ways" are - instead of expecting the reader to carry on reading. The sections below the paragraph will then just expand on the details (that's if the reader wants to know more - they may not but at least they'll know for sure that they don't - instead of having to wade through the whole topic before they decide, or worse just leave the topic because they can't be bothered and then are left unsure about whether the topic actually answers their questions). How about something like this (based on info in the OpenAPI guide and my basic understanding - so get it tech reviewed again!): "OpenAPI (previously known as Swagger) defines a standard interface for documenting and exposing RESTful APIs. This standard interface enables both humans and computers to understand or process the capabilities of a web service that are available through its REST API without requiring direct access to the underlying source code of the web service. MicroProfile OpenAPI provides a set of Java interfaces and programming models that enable Java developers to natively produce OpenAPI documents from their JAX-RS applications. Another developer can only use the REST API in their own web service (e.g. to request information) if they know what information they can request from the API and what information the API needs from them to be able to return relevant information. (re-word this to make a bit more sense!) It is important to document APIs when they are published so that other developers can use them. There are two main ways to generate an link:https://swagger.io/docs/specification/about/[OpenAPI] document. The developer can generate documentation of the REST API from the source code of the REST API itself. This produces a reference document that lists all the API endpoints and descriptions of how to use them. Alternatively, the developer can start by designing the API in the form of structured documentation that they can then augment with annotations in the code. The developer can even generate the stubs for the source code (including client libraries for the API) from this manually-created documentation." Sub-sections of the topic Currently, the sub-sections in the topic, whilst technically accurate, don't give much context to the technical information, so it's not clear what they're referring to. For example, with the last sentence of the introductory section ending with "…in multiple ways.", it would be reasonable for the reader to expect that each of the five sub-headings is one of those multiple ways of generating API docs, when that's not actually the case. Again, it just needs more writing around it (and more meaningful headings) to make it easier for the reader to understand what they're reading and to know what's relevant or not to them. Annotations section So, you could change the heading "Annotations" from focusing on the technology to something more focused on what the user gets from it, such as "Generated REST API documentation". Then the section can explain that you generate documentation for the REST APIs that you write by adding annotations to your JAX-RS code. JAX-RS framework handles the basic API docs generation but by adding annotations to your code, you can provide more useful explanation of the parts of the API. I don't think it's necessary to say that "MP OpenAPI processes JAX-RS annotations by default." (I know the guide says that but I'm not sure it gives much value). The important thing is that the developer wants API documentation, JAX-RS can generate most of it, but the developer can and probably should provide additional details/explanation about the methods etc. Don't talk about "vendors" - that refers to projects/companies who are implementing the spec - the developer doesn't care how or why it was implemented - they just want to use the implementation. Going back to the 'inverted pyramid' approach, how JAX-RS generates the docs is not as important to the developer as what they can or should do. So focus on that first. The less value a piece of information has to the reader, the later on it should be presented to them (there's no correct/incorrect answer to doing this, it just takes practice and thought). Give an explanation of what the annotations are for and why you'd use them as a developer of a RESTful API: @GET
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(
responseCode = "200",
description = "host:properties pairs stored in the inventory.",
content = @Content(
mediaType = "application/json",
schema = @Schema(
type = SchemaType.OBJECT,
implementation = InventoryList.class)))
@Operation(
summary = "List inventory contents.",
description = "Returns the currently stored host:properties pairs in the "
+ "inventory.")
public InventoryList listContents() {
return manager.list();
} In the following OpenAPI documentation example that is generated from the example code, the JAX-RS framework generates the path
The information provided through the OpenAPI annotations augment the basic API documentation that is generated by the JAX-RS framework." Remove the paragraph starting "Annotations like @callback…" as that's about what annotations are - we should be able to assume the developer knows that to be reading this topic or writing modern Java. The paragraph starting "When the same annotation is used…" is useful though the examples given need more clarification (eg what are It's good that you've found annotation examples and you're right not to reproduce that whole set of info in this topic, but those examples should be in the annotations Javadoc so that you can just link to them from this topic (I've raised an issue to update the Javadoc - we'll see what the developers say and, if it gets done, you can add a bit to this topic saying that examples of the annotations are available in the relevant Javadoc). In the meantime, you could link to the higher level javadoc page for a list of available OpenAPI annotations - check this link with the tech reviewer. Static OpenAPI files section Start by introducing the idea of manually creating the API doc and that the approach is focused on designing the API before implementing it (the third and fourth sentences in your first para are alluding to this in a roundabout way but need to be more concrete). Don't talk about the /openapi location at the start of the section - focus instead on what the developer cares about most: what does it mean to manually create the doc and why would you do it when the alternative is to generate it from the API automatically? "lock in the API contract" is too jargon-y, and "client and provider" isn't very clear who you're talking about. The point that you've got about enterprises is about how, in an enterprise (or big company), you need consistent, usable APIs so APIs should be designed and reviewed/approved, not just cobbled together. Doing that up-front means that you then have a document that's agreed between the relevant people that that's a good API design, and the API must be implemented following that design. Then give the basic details about what format the doc file should be in (json/yaml) and the location in which it should go. Then something about how you can use create a complete doc or just a partially complete doc manually, that can be augmented by adding annotations in the code as described in the previous section. Link to the OpenAPI guide to give an example of a well-structured complete yaml file (unless your tech reviewer can give you a nice short example to include here and explain concisely, which would be nicer - can link to the guide as well for a longer version). Programming model section Filter section Provide an example of a filter method from the guide (see https://openliberty.io/guides/microprofile-openapi.html#filtering-the-openapi-tree-elements). It might make sense to move this section to be a sub-section of the generating doc section above (as it's only really relevant to the generated doc - if you were writing the doc manually, I think you'd just leave it out? check that assumption with the tech reviewer though). OpenAPI UI section This section needs to introduce what the UI is. Start by saying that the documentation that is generated or manually created is available at xxx endpoint of your web service. Then you can say that the format of the doc is defined by a default stylesheet but you can optionally customize the stylesheet. Don't link from the OL docs to the KC. If we need info from the KC, we need to write it in the OL docs (raise an issue on the OL docs backlog if necessary). In this particular case, it might be that you can provide a condensed version of the KC info in this section (I'm not sure - it might be too much but you could give it a go and see if it makes this topic look too long). It might be we need to move this whole section to its own topic, but keep it here for now and we can see how it looks. |
Draft link for the issue https://draft-openlibertyio.mybluemix.net/docs/ref/general/#mp-openapi.html |
I don't see any changes in the topic on the draft website or in the |
Also, can you change the topic title to "Documenting microservice APIs with OpenAPI" as it's more meaningful. |
@lauracowen I'm working on the changes you suggested. I added the draft link during a meeting as it was suggested. Will update your edit suggestions in the doc and update in the issue. |
Thanks for making the changes to the first part of the article. I've some comments on that but also can you address the later sections with the feedback I gave previously?
|
Thank you - looking better.
|
I'm moving this out of 'ready to publish' because I think it needs an editorial/proofread review. There are minor grammatical/punctuation/spelling typos (eg "port" instead of "part"). Also, has this topic been re-reviewed by the technical SME since making significant changes to the wordings? If so, please record it here (there needs to be a record - ideally paste in the feedback you received from him here too). If not, can you get them to check the assertions made in this topic? We shouldn't link to the spec from docs - the spec is written for the app server developers (eg the Open Liberty dev team) to implement, not for the end-user. If the filters are useful to the end-user (developer), which I think they seem to be, this topic should contain a short section explaining what they are and why they are worth using. I think you had an ok filtering section before that just needed tidying up. Link to Javadoc - I don't see any lists of annotations at that link, can you check it? I think my issue to add all the examples to the Javadoc is still not addressed (microprofile/microprofile-open-api#405) so if that's what you were intending to link to, maybe it's not worth doing for now. Might just have to link to the wiki page like you've done further down for the filter samples. I don't think we should be linking to the wiki really but we might need to for the short-term then update the links later. Can you create an issue on the docs backlog to update any links in this topic that currently point to the wiki to point to the javadoc? Provide a link to my github issue so we can check from time-to-time if it's been fixed yet. Can you also provide a link to the MP OpenAPI guide? Also, don't abbreviate to "MP OpenAPI". Just use the full name. |
Artur's comments, |
@lauracowen Can you review this draft |
@chirp1 Can you review this draft |
Just a couple of comments this time: The code-first approach
|
@msmiths Here is a link to the draft with the updates https://draft-openlibertyio.mybluemix.net/docs/21.0.0.2/documentation-openapi.html
|
@ManasiGandhi That looks better. No further comments from me. |
Content reviewNice work on this! Intro
The code-first approach
The design-first approach
Filter components in and out of API documentation
Viewing and formatting API documentation
|
@dmuelle I worked on your reveiw
|
Hi @ManasiGandhi - changes look good, just a few more items in the new draft: Intro
The design-first approach
Filter components in and out of API documentationThis section seems very sparse. Can you apply filters to manually-created API docs? If not, I'd recommend moving this section to be a sub-section of the code first approach. If so, make it clear that you can apply filters either in the code or to the manually created docs. I also think you need a concise statement of the value of filtering. Why might someone want to add or remove content? Instead of linking on the word "filters", I'd recommend adding a sentence to the end of the section that says, "For more information, see [Filtering the OpenAPI tree elements]. View API documentationThis section is also really thin. I think you should introduce the UI and explain the difference in obtaining the "raw" document vs the ui, per Martin's comment. Also for the example URL, it shouldn't be hyperlinked to "endpoint"- because it doesn't resolve to anything. I was suggesting to provide that example for how a user might construct their own URL. Like: "You can view the API documents by pointing your browser to the endpoint URL, for example That is consistent with how we have demonstrated endpoint URLs elsewhere in the OL docs but verify with the SME that it is a viable example in this case.
|
Hi @dmuelle - I worked on your edits. https://draft-openlibertyio.mybluemix.net/docs/21.0.0.3/documentation-openapi.html
The design-first approach
This section seems very sparse. Can you apply filters to manually-created API docs? If not, I'd recommend moving this section to be a sub-section of the code first approach. If so, make it clear that you can apply filters either in the code or to the manually created docs. (Artur mentioned that filtering is for advanced use cases, so the section is short. "Can you apply filters to manually-created API docs", Martin mentioned in his comments that filtering is done before the document is generated. I slacked Martin, waiting for his response) I also think you need a concise statement of the value of filtering. Why might someone want to add or remove content? Instead of linking on the word "filters", I'd recommend adding a sentence to the end of the section that says, "For more information, see [Filtering the OpenAPI tree elements]. View API documentation
Also for the example URL, it shouldn't be hyperlinked to "endpoint"- because it doesn't resolve to anything. I was suggesting to provide that example for how a user might construct their own URL. Like: "You can view the API documents by pointing your browser to the endpoint URL, for example http://localhost:9443/openapi/ui, where where localhost is your hostname and 9443 is the port number for your application. " That is consistent with how we have demonstrated endpoint URLs elsewhere in the OL docs but verify with the SME that it is a viable example in this case.
---> |
Hi Manasi- doc looks good! Just a couple minor Acrolinx issues to address:
|
changes look good, signing off |
Peer reviewThe topic looks good, I just have a few comments: Introduction
The code-first approach
The design-first approach
Filter components in and out of API documentation
View API documentation
|
@rw2513 Hi Richard. I worked on your peer review. https://draft-openlibertyio.mybluemix.net/docs/21.0.0.3/documentation-openapi.html
|
@ManasiGandhi Thanks, your updates look good. |
Target audience: developer of a microservice
Some background: OpenAPI is a mechanism for generating structured documentation (eg HTML pages) of the APIs in a microservice. When you have written an API for your microservice, you can generate documentation about it so that other developers can look up how to use your API in their own microservice (so that their microservice can call yours). There are alternative ways to create the API doc, including writing the API doc first and generating the API itself from the doc. The OL OpenAPI guide (see below) describes the different approaches nicely.
In the topic, introduce MP OpenAPI, mention the multiple approaches (all are shown in the guide so we need to support that) but talk primarily about the annotations approach. Then the alternative approaches and when is most appropriate to use each of them. Explain it simply as in the guide, not directly taken from the spec (the guide explains it much more clearly).
See also the KC topic but don't include the 'avoid trouble' box from the KC topic; instead, move that info into a separate general troubleshooting topic (talk to Laura/Alasdair about where this should go) and then link to the troubleshooting topic.
Sources of info:
Related links to include:
Background research:
Contact:
The text was updated successfully, but these errors were encountered: