{"id":32202,"date":"2014-10-29T22:00:25","date_gmt":"2014-10-29T20:00:25","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=32202"},"modified":"2014-10-28T22:53:41","modified_gmt":"2014-10-28T20:53:41","slug":"spring-rest-api-with-swagger-creating-documentation","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html","title":{"rendered":"Spring Rest API with Swagger \u2013 Creating documentation"},"content":{"rendered":"<p>The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company processes right to publish it correctly and on time. Ensuring that stakeholders receive it on time is one thing, but you are also responsible for updates in both the API and documentation. Having this process done automatically provides easy way out of trouble, since your documentation is no longer static deliverable and becomes a living thing. In previous post, I discussed how to integrate Swagger with your Spring application with Jersey. Now it\u2019s time to show you how to create documentation and publish it for others to see.<\/p>\n<p>Before I get down to the actual documentation, lets start with a few notes on its form and properties. We will be using annotations to supply metadata to our API which answers question how. But what about why? On one hand we are supplying new annotations to already annotation ridden places like API endpoints or controllers (in case of integration with Spring MVC). But on the other, this approach has a standout advantage in binding release cycle of application, API and documentation in one delivery. Using this approach allows us to create and manage small cohesive units ensuring proper segmentation of documentation and its versioning as well.<\/p>\n<h2>Creating endpoint documentation<\/h2>\n<p>Everything starts right on top of your endpoint. In order to make Swagger aware of your endpoint, you need to annotate your class with <code>@Api<\/code> annotation. Basically, all you want to do here is name your endpoint and provide some description for your users. This is exactly what I am doing in the following code snippet. If you feel the need to go into more detail with your API documentation, check out <code>@Api<\/code> annotation description below.<\/p>\n<pre class=\" brush:java\">package com.jakubstas.swagger.rest;\r\n\r\n\/**\r\n * REST endpoint for user manipulation.\r\n *\/\r\n@Api(value = \"users\", description = \"Endpoint for user management\")\r\n@Path(\"\/users\")\r\npublic class UsersEndpoint {\r\n    ...\r\n}<\/pre>\n<p>To verify the results just enter the URL from your <code>basePath<\/code> variable followed by <code>\/api-docs<\/code> into your browser. This is the place where resource listing for your APIs resides. You can expect something similar to\u00a0following snippet I received after annotating three of my endpoints and accessing\u00a0<code>http:\/\/[hostname]:[port]\/SpringWithSwagger\/rest\/api-docs\/<\/code>:<\/p>\n<pre class=\" brush:bash\">{\r\n    \"apiVersion\":\"1.0\",\r\n    \"swaggerVersion\":\"1.2\",\r\n    \"apis\":[\r\n        {\r\n            \"path\":\"\/users\",\r\n            \"description\":\"Endpoint for user management\"\r\n        },\r\n        {\r\n            \"path\":\"\/products\",\r\n            \"description\":\"Endpoint for product management\"\r\n        },\r\n        {\r\n            \"path\":\"\/employees\",\r\n            \"description\":\"Endpoint for employee listing\"\r\n        }\r\n    ]\r\n}<\/pre>\n<p>However, please note that in order for an API to appear in APIs listing you have to annotate at least one API method with Swagger annotations. If none\u00a0of your methods is\u00a0annotated\u00a0(or you haven\u2019t provided any methods yet), API documentation will not be processed and published.<\/p>\n<h4>@Api annotation<\/h4>\n<p>Describes a top-level api. Classes with <code>@Api<\/code> annotations will be included in the resource listing.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>value <\/code>&#8211; Short description of the Api<\/li>\n<li><code>description <\/code>&#8211; general description of this class<\/li>\n<li><code>basePath <\/code>&#8211; the base path that is prepended to all <code>@Path<\/code> elements<\/li>\n<li><code>position <\/code>&#8211; optional explicit ordering of this Api in the resource listing<\/li>\n<li><code>produces <\/code>&#8211; content type produced by this Api<\/li>\n<li><code>consumes <\/code>&#8211; media type consumed by this Api<\/li>\n<li><code>protocols <\/code>&#8211; protocols that this Api requires (i.e. https)<\/li>\n<li><code>authorizations <\/code>&#8211; authorizations required by this Api<\/li>\n<\/ul>\n<h3>Operations documentation<\/h3>\n<p>Now, lets move on to the key part of API documentation. There are basically two main parts of operation documentation \u2013 operation description and response description. Lets start with operation description. Using annotation <code>@ApiOperation<\/code> provides detailed description of what certain method does, its response, HTTP method and other useful information presented in annotation description below. Example of operation declaration for Swagger can be seen in the following code sample.<\/p>\n<h4>@ApiOperation annotation<\/h4>\n<p>Describes an operation or typically a <code>HTTP<\/code> method against a specific path. Operations\u00a0with equivalent paths are grouped in an array in the Api declaration.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>value<\/code> \u2013 brief description of the operation<\/li>\n<li><code>notes<\/code> \u2013 long description of the operation<\/li>\n<li><code>response<\/code> \u2013 default response class from the operation<\/li>\n<li><code>responseContainer<\/code> \u2013 if the response class is within a container, specify it here<\/li>\n<li><code>tags<\/code> \u2013 currently not implemented in readers, reserved for future use<\/li>\n<li><code>httpMethod<\/code> \u2013 the <code>HTTP<\/code> method, i.e <code>GET<\/code>, <code>PUT<\/code>, <code>POST<\/code>, <code>DELETE<\/code>, <code>PATCH<\/code>, <code>OPTIONS<\/code><\/li>\n<li><code>position<\/code> \u2013 allow explicit ordering of operations inside the Api declaration<\/li>\n<li><code>nickname<\/code> \u2013 the nickname for the operation, to override what is detected by the annotation scanner<\/li>\n<li><code>produces<\/code> \u2013 content type produced by this Api<\/li>\n<li><code>consumes<\/code> \u2013 media type consumed by this Api<\/li>\n<li><code>protocols<\/code> \u2013 protocols that this Api requires (i.e. https)<\/li>\n<li><code>authorizations<\/code> \u2013 authorizations required by this Api<\/li>\n<\/ul>\n<p>You may\u00a0notice the use of response parameter in <code>@ApiOperation<\/code> annotation that specifies type of response (return type) from the operation. As you can see this value can be different from method return type, since it serves only for purposes of API documentation.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java;wrap-lines:false\">@GET\r\n@Path(\"\/{userName}\")\r\n@Produces(MediaType.APPLICATION_JSON)\r\n@ApiOperation(value = \"Returns user details\", notes = \"Returns a complete list of users details with a date of last modification.\", response = User.class)\r\n@ApiResponses(value = {\r\n    @ApiResponse(code = 200, message = \"Successful retrieval of user detail\", response = User.class),\r\n    @ApiResponse(code = 404, message = \"User with given username does not exist\"),\r\n    @ApiResponse(code = 500, message = \"Internal server error\")}\r\n)\r\npublic Response getUser(@ApiParam(name = \"userName\", value = \"Alphanumeric login to the application\", required = true) @PathParam(\"userName\") String userName) {\r\n    ...\r\n}<\/pre>\n<p>Next, take a look at the use of <code>@ApiParam<\/code>. It is always useful to describe to the client what you need in order to fulfill their request. This is the primary aim of <code>@ApiParam<\/code> annotation. Whether you are working with path or query parameter, you should always provide clarification of what this parameter represents.<\/p>\n<h4>@ApiParam annotation<\/h4>\n<p>Represents a single parameter in an Api Operation. A parameter is an input to the operation.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>name<\/code> \u2013 name of the parameter<\/li>\n<li><code>value<\/code> \u2013 description of the parameter<\/li>\n<li><code>defaultValue<\/code> \u2013 default value \u2013 if e.g. no JAX-RS <code>@DefaultValue<\/code> is given<\/li>\n<li><code>allowableValues<\/code> \u2013 description of values this endpoint accepts<\/li>\n<li><code>required<\/code> \u2013 specifies if the parameter is required or not<\/li>\n<li><code>access<\/code> \u2013 specify an optional access value for filtering in a <code>Filter<\/code> implementation. This allows you to hide certain parameters if a user doesn\u2019t have access to them<\/li>\n<li><code>allowMultiple<\/code> \u2013 specifies whether or not the parameter can have multiple values provided<\/li>\n<\/ul>\n<p>Finally, lets look at the way of documenting the actual method responses in terms of messages and HTTP codes. Swagger comes with <code>@ApiResponse<\/code> annotation, which can be used multiple times when it\u2019s wrapped using <code>@ApiResponses<\/code> wrapper. This way you can cover all alternative execution flows of your code and provide full API operation description for clients of your API. Each response can be described in terms of HTTP return code, description of result and type of the result. For more details about <code>@ApiResponse<\/code> see description below.<\/p>\n<h4>@ApiResponse annotation<\/h4>\n<p>An <code>ApiResponse<\/code> represents a type of response from a server. This can be used to describe both success codes as well as errors. If your Api has different response classes, you can describe them here by associating a response class with a response code. Note, Swagger does not allow multiple response types for a single response code.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>code<\/code> \u2013 response code to describe<\/li>\n<li><code>message<\/code> \u2013 human-readable message to accompany the response<\/li>\n<li><code>response<\/code> \u2013 optional response class to describe the payload of the message<\/li>\n<\/ul>\n<p>Using these annotations is pretty simple and provides nicely structured approach to describing features of your API. If you want to check what your documentation looks like just enter the URL pointing to the API documentation of one of your endpoints\u00a0by appending the\u00a0value of parameter <code>value<\/code> from <code>@Api<\/code> annotation to the URL pointing to resource listing. Be careful no to enter the value of <code>@Path<\/code> annotation be mistake (unless they have the same value). In case of my example desired URL is\u00a0<code>http:\/\/[hostname]:[port]\/SpringWithSwagger\/rest\/api-docs\/users<\/code>. You should be able to see output similar to following snippet:<\/p>\n<pre class=\" brush:java;wrap-lines:false\">{  \r\n    \"apiVersion\":\"1.0\",\r\n    \"swaggerVersion\":\"1.2\",\r\n    \"basePath\":\"http:\/\/[hostname\/ip address]:[port]\/SpringWithSwagger\/rest\",\r\n    \"resourcePath\":\"\/users\",\r\n    \"apis\":[  \r\n        {  \r\n            \"path\":\"\/users\/{userName}\",\r\n            \"operations\":[  \r\n                {  \r\n                    \"method\":\"GET\",\r\n                    \"summary\":\"Returns user details\",\r\n                    \"notes\":\"Returns a complete list of users details with a date of last modification.\",\r\n                    \"type\":\"User\",\r\n                    \"nickname\":\"getUser\",\r\n                    \"produces\":[  \r\n                        \"application\/json\"\r\n                    ],\r\n                    \"authorizations\":{  \r\n\r\n                    },\r\n                    \"parameters\":[  \r\n                        {  \r\n                            \"name\":\"userName\",\r\n                            \"description\":\"Alphanumeric login to application\",\r\n                            \"required\":true,\r\n                            \"type\":\"string\",\r\n                            \"paramType\":\"path\",\r\n                            \"allowMultiple\":false\r\n                        }\r\n                    ],\r\n                    \"responseMessages\":[  \r\n                        {  \r\n                            \"code\":200,\r\n                            \"message\":\"Successful retrieval of user detail\",\r\n                            \"responseModel\":\"User\"\r\n                        },\r\n                        {  \r\n                            \"code\":404,\r\n                            \"message\":\"User with given username does not exist\"\r\n                        },\r\n                        {  \r\n                            \"code\":500,\r\n                            \"message\":\"Internal server error\"\r\n                        }\r\n                    ]\r\n                }\r\n            ]\r\n        }\r\n    ],\r\n    \"models\":{\r\n        \"User\":{\r\n            \"id\":\"User\",\r\n            \"properties\": {\r\n                \"surname\":{\"type\":\"string\"},\r\n                \"userName\":{\"type\":\"string\"},\r\n                \"lastUpdated\":\r\n                    {\r\n                        \"type\":\"string\",\r\n                        \"format\":\"date-time\"\r\n                    },\r\n                \"avatar\":{\r\n                    \"type\":\"array\",\r\n                    \"items\":{\"type\":\"byte\"}\r\n                },\r\n                \"firstName\":{\"type\":\"string\"},\r\n                \"email\":{\"type\":\"string\"}\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<h2>Creating model documentation<\/h2>\n<p>By supplying <code>User<\/code> class to the response parameter of several annotations in previous example, I\u2019ve managed to introduce new undocumented element into my API documentation. Swagger was able to pull out all the structural data about <code>User<\/code> class with no regard for its relevance to the API. To counter this effect, Swagger provides two annotations to provide additional information to the users of your API and restrict visibility of your model. To mark a model class for processing by Swagger just place <code>@ApiModel<\/code> on top of your class. As usual, you can provide description as well as inheritance configuration. For more information see <code>@ApiModel<\/code> description below.<\/p>\n<h4>@ApiModel annotation<\/h4>\n<p>A bean class used in the REST-api. Suppose you have an interface <code>@PUT @ApiOperation(...) void foo(FooBean fooBean)<\/code>, there is no direct way to see what fields <code>FooBean<\/code> would have. This annotation is meant to give a description of <code>FooBean<\/code> and then have the fields of it be annotated with <code>@ApiModelProperty<\/code>.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>value<\/code> \u2013 provide a synopsis of this class<\/li>\n<li><code>description<\/code> \u2013 provide a longer description of the class<\/li>\n<li><code>parent<\/code> \u2013 provide a superclass for the model to allow describing inheritence<\/li>\n<li><code>discriminator<\/code> \u2013 for models with a base class, a discriminator can be provided for polymorphic use cases<\/li>\n<li><code>subTypes<\/code><\/li>\n<\/ul>\n<p>Last thing you need to do is to annotate class members with <code>@ApiModelProperty<\/code> annotation to provide documentation for each class member. Simple example of this can be seen in the following class.<\/p>\n<pre class=\" brush:java;wrap-lines:false\">package com.jakubstas.swagger.model;\r\n\r\n@ApiModel\r\npublic class User {\r\n\r\n    private String userName;\r\n\r\n    private String firstName;\r\n\r\n    private String surname;\r\n\r\n    private String email;\r\n\r\n    private byte[] avatar;\r\n\r\n    private Date lastUpdated;\r\n\r\n    @ApiModelProperty(position = 1, required = true, value = \"username containing only lowercase letters or numbers\")\r\n    public String getUserName() {\r\n        return userName;\r\n    }\r\n\r\n    public void setUserName(String userName) {\r\n        this.userName = userName;\r\n    }\r\n\r\n    @ApiModelProperty(position = 2, required = true)\r\n    public String getFirstName() {\r\n        return firstName;\r\n    }\r\n\r\n    public void setFirstName(String firstName) {\r\n        this.firstName = firstName;\r\n    }\r\n\r\n    @ApiModelProperty(position = 3, required = true)\r\n    public String getSurname() {\r\n        return surname;\r\n    }\r\n\r\n    public void setSurname(String surname) {\r\n        this.surname = surname;\r\n    }\r\n\r\n    @ApiModelProperty(position = 4, required = true)\r\n    public String getEmail() {\r\n        return email;\r\n    }\r\n\r\n    public void setEmail(String email) {\r\n        this.email = email;\r\n    }\r\n\r\n    @JsonIgnore\r\n    public byte[] getAvatar() {\r\n        return avatar;\r\n    }\r\n\r\n    public void setAvatar(byte[] avatar) {\r\n        this.avatar = avatar;\r\n    }\r\n\r\n    @ApiModelProperty(position = 5, value = \"timestamp of last modification\")\r\n    public Date getLastUpdated() {\r\n        return lastUpdated;\r\n    }\r\n\r\n    public void setLastUpdated(Date lastUpdated) {\r\n        this.lastUpdated = lastUpdated;\r\n    }\r\n}<\/pre>\n<p>If you need to provide more details about your model, check following description of <code>@ApiModelProperty<\/code>:<\/p>\n<h4>@ApiModelProperty annotation<\/h4>\n<p>An ApiModelProperty describes a property inside a model class. The annotations can\u00a0apply to a method, a property, etc., depending on how the model scanner is configured and\u00a0used.<\/p>\n<p>Annotation parameters:<\/p>\n<ul>\n<li><code>value<\/code> \u2013 Provide a human readable synopsis of this property<\/li>\n<li><code>allowableValues<\/code> \u2013 If the values that can be set are restricted, they can be set here. In the form of a comma separated list <code>registered, active, closed<\/code><\/li>\n<li><code>access<\/code> \u2013 specify an optional access value for filtering in a <code>Filter<\/code> implementation. This allows you to hide certain parameters if a user doesn\u2019t have access to them<\/li>\n<li><code>notes<\/code> \u2013 long description of the property<\/li>\n<li><code>dataType<\/code> \u2013 The dataType. See the documentation for the supported datatypes. If the data type is a custom object, set it\u2019s name, or nothing. In case of an enum use \u2018string\u2019 and allowableValues for the enum constants<\/li>\n<li><code>required<\/code> \u2013 Whether or not the property is required, defaults to false<\/li>\n<li><code>position<\/code> \u2013 allows explicitly ordering the property in the model. Since reflection has no guarantee on ordering, you should specify property order to keep models consistent across different VM implementations and versions<\/li>\n<\/ul>\n<p>If you follow these instructions carefully, you should end up with complete API documentation in json on previously mentioned URL. Following is only model related part of resulting json, now with provided documentation.<\/p>\n<pre class=\" brush:bash\">{\r\n    ...\r\n    \"models\":{  \r\n        \"User\":{  \r\n            \"id\":\"User\",\r\n            \"description\":\"\",\r\n            \"required\":[  \r\n                \"userName\",\r\n                \"firstName\",\r\n                \"surname\",\r\n                \"email\"\r\n            ],\r\n            \"properties\":{  \r\n                \"userName\":{  \r\n                    \"type\":\"string\",\r\n                    \"description\":\"username containing only lowercase letters or numbers\"\r\n                },\r\n                \"firstName\":{  \r\n                    \"type\":\"string\"\r\n                },\r\n                \"surname\":{  \r\n                    \"type\":\"string\"\r\n                },\r\n                \"email\":{  \r\n                    \"type\":\"string\"\r\n                },\r\n                \"lastUpdated\":{  \r\n                    \"type\":\"string\",\r\n                    \"format\":\"date-time\",\r\n                    \"description\":\"timestamp of last modification\"\r\n                }\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<h2>What is next?<\/h2>\n<p>If you followed all steps you should now have working API documentation that may be published or further processed by automation tools. I will showcase how\u00a0to present\u00a0API documentation using <a href=\"http:\/\/petstore.swagger.wordnik.com\/\" target=\"_blank\">Swagger UI<\/a> module in my next article called\u00a0Spring Rest API with Swagger \u2013 Exposing documentation. The code used in this micro series is published on GitHub and provides examples for all discussed features and tools. Please enjoy!<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/jakubstas.com\/spring-jersey-swagger-create-documentation\/\">Spring Rest API with Swagger \u2013 Creating documentation<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\/\">JCG partner<\/a> Jakub Stas at the <a href=\"http:\/\/jakubstas.com\/\">Jakub Stas<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company processes right to publish it correctly and on time. Ensuring that stakeholders receive it on time is one thing, but you are also responsible for updates in &hellip;<\/p>\n","protected":false},"author":569,"featured_media":28690,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[219,54,30,1029],"class_list":["post-32202","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jersey","tag-restful-web-services","tag-spring","tag-swagger"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Rest API with Swagger \u2013 Creating documentation<\/title>\n<meta name=\"description\" content=\"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Rest API with Swagger \u2013 Creating documentation\" \/>\n<meta property=\"og:description\" content=\"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-29T20:00:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jakub Stas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@jakub_stas\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jakub Stas\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html\"},\"author\":{\"name\":\"Jakub Stas\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/2927b40b7959304127862052f0a267ab\"},\"headline\":\"Spring Rest API with Swagger \u2013 Creating documentation\",\"datePublished\":\"2014-10-29T20:00:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html\"},\"wordCount\":1633,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/Jersey-logo.jpg\",\"keywords\":[\"Jersey\",\"RESTful Web Services\",\"Spring\",\"Swagger\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html\",\"name\":\"Spring Rest API with Swagger \u2013 Creating documentation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/Jersey-logo.jpg\",\"datePublished\":\"2014-10-29T20:00:25+00:00\",\"description\":\"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/Jersey-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2014\\\/08\\\/Jersey-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2014\\\/10\\\/spring-rest-api-with-swagger-creating-documentation.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Rest API with Swagger \u2013 Creating documentation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/2927b40b7959304127862052f0a267ab\",\"name\":\"Jakub Stas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g\",\"caption\":\"Jakub Stas\"},\"sameAs\":[\"http:\\\/\\\/jakubstas.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/jakubstas\",\"https:\\\/\\\/x.com\\\/jakub_stas\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/jakub-stas\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Rest API with Swagger \u2013 Creating documentation","description":"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html","og_locale":"en_US","og_type":"article","og_title":"Spring Rest API with Swagger \u2013 Creating documentation","og_description":"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company","og_url":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2014-10-29T20:00:25+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg","type":"image\/jpeg"}],"author":"Jakub Stas","twitter_card":"summary_large_image","twitter_creator":"@jakub_stas","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jakub Stas","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html"},"author":{"name":"Jakub Stas","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/2927b40b7959304127862052f0a267ab"},"headline":"Spring Rest API with Swagger \u2013 Creating documentation","datePublished":"2014-10-29T20:00:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html"},"wordCount":1633,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg","keywords":["Jersey","RESTful Web Services","Spring","Swagger"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html","url":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html","name":"Spring Rest API with Swagger \u2013 Creating documentation","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg","datePublished":"2014-10-29T20:00:25+00:00","description":"The real key to making your REST API easy to use is good documentation. But even if your documentation is done well, you need to set your company","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2014\/08\/Jersey-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2014\/10\/spring-rest-api-with-swagger-creating-documentation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Rest API with Swagger \u2013 Creating documentation"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/2927b40b7959304127862052f0a267ab","name":"Jakub Stas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0702ca1cf6a3bcd1926cba7c5b1d9a17b016a8cff098389e8f5f1cd22837a1c6?s=96&d=mm&r=g","caption":"Jakub Stas"},"sameAs":["http:\/\/jakubstas.com\/","https:\/\/www.linkedin.com\/in\/jakubstas","https:\/\/x.com\/jakub_stas"],"url":"https:\/\/www.javacodegeeks.com\/author\/jakub-stas"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/32202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/569"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=32202"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/32202\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/28690"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=32202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=32202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=32202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}