How to get the Swagger schema for a specific version of a Swagger API? - spring-boot

I know I can add a /v3/api-docs/ to the end of my APIs endpoint to get a JSON representation of my APIs schema.
Is there a way to get the schema for a specific version of the API?

In our case, we have a versioned API.
The below URI was our entire JSON schema including all API versions.
.../v3/api-docs
But, the below URI was scoped only to a specific API version.
.../v3/api-docs/v2-tool
The v2-tool corresponds to a namespace specific to our code.

Related

Is there any way to create API documentation for graphql end points in a spring boot project

I have a springboot microservice project and I am using graphql. For REST api end points I am aware that we can document using swagger etc.. Graphiql also provides dynamic documentation but is there any other way to create API documentation for the customers who are not so aware of how graphql or Graphiql works.
aaah that might help: You can get (and print) the generated schema programatically:
How to get the generated scheme file .graphqls using SPQR?

Spring Rest docs - i18n support

im currently thinking how to build REST API docs for my application with support for multiple languages. Endpoints, parameter names and return values should stay the same but the description of each REST method i want to provide in different supported languages.
Im using Spring boot, data & rest and found this docs project what seems very useful to me. Anyway, i couldn't find any informations in the docs regards the i18n topic/support.
Does anybody know if Spring REST docs support the generation of the API doc for multiple languages (in general)?
REST Docs doesn't provide any out-of-the-box support for I18N but it should be pretty straightforward to build something on top.
The main piece with which REST Docs is involved and that I think you'd want to translate are the descriptions that are included in the various snippets. Rather than hard-coding a particular description, you could look each up in a ResourceBundle:
ResourceBundle resourceBundle = ResourceBundle.getBundle("field-descriptions");
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("example", responseFields(
fieldWithPath("a").description(resourceBundle.getString("a")),
fieldWithPath("a.b").description(resourceBundle.getString("a.b")))));

Mocking Rest Api with Swagger Documentation

Whole idea is to create Mock service for UI guys to test without actual api.
- We have define specification in .ymcl files.
- Now want to generate Swagger-UI and Mock rest URI with mock data.
- Using spring-boot.
Please suggest some way to generate the same.
Given that you've the API documented in Swagger/OpenAPI spec (YAML format), you can use Swagger Codegen to generate Spring boot server stub.
Please pull the latest master of https://github.com/swagger-api/swagger-codegen and follow the instruction in the wiki:
https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO#java-springboot

How to configure a named resource stream using OData in ASP.NET Web API

I am creating OData endpoints using ASP.NET Web API using v5.8.0 of this NuGet package. I have everything working and I can retrieve simple data such as strings and ints without an issue. However I would now like to extend one of the endpoints so that one of the items that can be retrieved is a binary image file. Having read up on OData I have decided to use named resource streams to achieve this.
The problem I have is that I can find very little information on how to implement this using the ODataController. The closest I can find is this blog post but it is using an older version of Web API and the code does not compile when I use it in my project.
So can somebody please supply a working example of how this should be implemented please.
Named streams (aka stream properties) are not currently supported in Web API OData (for OData v4). See the following issues:
Clarify the situation for streams
Document for Stream Support in OData V4

Getting the schema in swashbuck when using HttpResponseMessage, in WebApi

I'm attempting to use Swashbuckle to generate a swagger inteface for our API, we're returning HttpResponseMessage in our controller methods.
The docs indicate to use the [ResponseType(…)] attribute to indicate the actual return type. But that attribute is restricted to .net 4.5 (I believe, will gladly be proven wrong), and won't work in a .net4 project.
There are the XML comments, however I couldn't see how to use them the generate the schema information (I've taken a look through the unit tests in the project, but couldn't figure out if it's supported)

Resources