BAEL-3493: Spring REST Docs vs OpenAPI (#9295)

This commit is contained in:
Sampada
2020-05-16 02:07:36 +05:30
committed by GitHub
parent b707c20297
commit 708e85ce38
11 changed files with 672 additions and 2 deletions
@@ -5,4 +5,7 @@ springdoc.swagger-ui.path=/swagger-ui-custom.html
springdoc.api-docs.path=/api-docs
# H2 Related Configurations
spring.datasource.url=jdbc:h2:mem:springdoc
spring.datasource.url=jdbc:h2:mem:springdoc
springdoc.version=@springdoc.version@
spring.jpa.hibernate.ddl-auto=none
@@ -0,0 +1,153 @@
= RESTful Notes API Guide
Baeldung;
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 4
:sectlinks:
[[overview]]
= Overview
[[overview-http-verbs]]
== HTTP verbs
RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP verbs.
|===
| Verb | Usage
| `GET`
| Used to retrieve a resource
| `POST`
| Used to create a new resource
| `PUT`
| Used to update an existing resource
| `DELETE`
| Used to delete an existing resource
|===
RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its
use of HTTP status codes.
|===
| Status code | Usage
| `200 OK`
| The request completed successfully
| `201 Created`
| A new resource has been created successfully. The resource's URI is available from the response's
`Location` header
| `204 No Content`
| An update to an existing resource has been applied successfully
| `400 Bad Request`
| The request was malformed. The response body will include an error providing further information
| `404 Not Found`
| The requested resource did not exist
|===
[[overview-hypermedia]]
== Hypermedia
RESTful Notes uses hypermedia and resources include links to other resources in their
responses. Responses are in http://stateless.co/hal_specification.html[Hypertext Application
from resource to resource.
Language (HAL)] format. Links can be found beneath the `_links` key. Users of the API should
not create URIs themselves, instead they should use the above-described links to navigate
[[resources]]
= Resources
[[resources-FOO]]
== FOO REST Service
The FOO provides the entry point into the service.
[[resources-foo-get]]
=== Accessing the foo GET
A `GET` request is used to access the foo read.
==== Request structure
include::{snippets}/getAFoo/http-request.adoc[]
==== Path Parameters
include::{snippets}/getAFoo/path-parameters.adoc[]
==== Example response
include::{snippets}/getAFoo/http-response.adoc[]
==== CURL request
include::{snippets}/getAFoo/curl-request.adoc[]
[[resources-foo-post]]
=== Accessing the foo POST
A `POST` request is used to access the foo create.
==== Request structure
include::{snippets}/createFoo/http-request.adoc[]
==== Example response
include::{snippets}/createFoo/http-response.adoc[]
==== CURL request
include::{snippets}/createFoo/curl-request.adoc[]
[[resources-foo-delete]]
=== Accessing the foo DELETE
A `DELETE` request is used to access the foo delete.
==== Request structure
include::{snippets}/deleteFoo/http-request.adoc[]
==== Path Parameters
include::{snippets}/deleteFoo/path-parameters.adoc[]
==== Example response
include::{snippets}/deleteFoo/http-response.adoc[]
==== CURL request
include::{snippets}/deleteFoo/curl-request.adoc[]
[[resources-foo-put]]
=== Accessing the foo PUT
A `PUT` request is used to access the foo update.
==== Request structure
include::{snippets}/updateFoo/http-request.adoc[]
==== Path Parameters
include::{snippets}/updateFoo/path-parameters.adoc[]
==== Example response
include::{snippets}/updateFoo/http-response.adoc[]
==== CURL request
include::{snippets}/updateFoo/curl-request.adoc[]
@@ -0,0 +1,4 @@
INSERT INTO Foo(id, title, body) VALUES (1, 'Foo 1', 'Foo body 1');
INSERT INTO Foo(id, title, body) VALUES (2, 'Foo 2', 'Foo body 2');
INSERT INTO Foo(id, title, body) VALUES (3, 'Foo 3', 'Foo body 3');
@@ -0,0 +1,8 @@
DROP TABLE IF EXISTS foo;
CREATE TABLE foo (
id INTEGER NOT NULL AUTO_INCREMENT,
title VARCHAR(250) NOT NULL,
body VARCHAR(250),
PRIMARY KEY (id)
);