getbooks();
+
+ /**
+ * Creates a new instance of a `Book`.
+ */
+ @POST
+ @Consumes("application/json")
+ void createBook(Book data);
+
+ /**
+ * Gets the details of a single instance of a `Book`.
+ */
+ @Path("/{bookId}")
+ @GET
+ @Produces("application/json")
+ Book getBook(@PathParam("bookId") String bookId);
+
+ /**
+ * Updates an existing `Book`.
+ */
+ @Path("/{bookId}")
+ @PUT
+ @Consumes("application/json")
+ void updateBook(@PathParam("bookId") String bookId, Book data);
+
+ /**
+ * Deletes an existing `Book`.
+ */
+ @Path("/{bookId}")
+ @DELETE
+ void deleteBook(@PathParam("bookId") String bookId);
+}
diff --git a/src/main/java/io/example/library/api/beans/Author.java b/src/main/java/io/example/library/api/beans/Author.java
new file mode 100644
index 0000000..2bede09
--- /dev/null
+++ b/src/main/java/io/example/library/api/beans/Author.java
@@ -0,0 +1,60 @@
+
+package io.example.library.api.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+
+/**
+ * Root Type for Author
+ *
+ * The author of a book.
+ *
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "id",
+ "name",
+ "dob"
+})
+public class Author {
+
+ @JsonProperty("id")
+ private String id;
+ @JsonProperty("name")
+ private String name;
+ @JsonProperty("dob")
+ private String dob;
+
+ @JsonProperty("id")
+ public String getId() {
+ return id;
+ }
+
+ @JsonProperty("id")
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @JsonProperty("name")
+ public String getName() {
+ return name;
+ }
+
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @JsonProperty("dob")
+ public String getDob() {
+ return dob;
+ }
+
+ @JsonProperty("dob")
+ public void setDob(String dob) {
+ this.dob = dob;
+ }
+
+}
diff --git a/src/main/java/io/example/library/api/beans/Book.java b/src/main/java/io/example/library/api/beans/Book.java
new file mode 100644
index 0000000..81331fb
--- /dev/null
+++ b/src/main/java/io/example/library/api/beans/Book.java
@@ -0,0 +1,93 @@
+
+package io.example.library.api.beans;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyDescription;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+
+
+/**
+ * Root Type for Book
+ *
+ * Information about a book.
+ *
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@JsonPropertyOrder({
+ "ddsn",
+ "title",
+ "author",
+ "publish-date"
+})
+public class Book {
+
+ @JsonProperty("ddsn")
+ private String ddsn;
+ @JsonProperty("title")
+ private String title;
+ /**
+ * Root Type for Author
+ *
+ * The author of a book.
+ *
+ */
+ @JsonProperty("author")
+ @JsonPropertyDescription("The author of a book.")
+ private Author author;
+ @JsonProperty("publish-date")
+ private String publishDate;
+
+ @JsonProperty("ddsn")
+ public String getDdsn() {
+ return ddsn;
+ }
+
+ @JsonProperty("ddsn")
+ public void setDdsn(String ddsn) {
+ this.ddsn = ddsn;
+ }
+
+ @JsonProperty("title")
+ public String getTitle() {
+ return title;
+ }
+
+ @JsonProperty("title")
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Root Type for Author
+ *
+ * The author of a book.
+ *
+ */
+ @JsonProperty("author")
+ public Author getAuthor() {
+ return author;
+ }
+
+ /**
+ * Root Type for Author
+ *
+ * The author of a book.
+ *
+ */
+ @JsonProperty("author")
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+
+ @JsonProperty("publish-date")
+ public String getPublishDate() {
+ return publishDate;
+ }
+
+ @JsonProperty("publish-date")
+ public void setPublishDate(String publishDate) {
+ this.publishDate = publishDate;
+ }
+
+}
diff --git a/src/main/java/io/example/library/api/impl/AuthorsResourceImpl.java b/src/main/java/io/example/library/api/impl/AuthorsResourceImpl.java
new file mode 100644
index 0000000..bfc5789
--- /dev/null
+++ b/src/main/java/io/example/library/api/impl/AuthorsResourceImpl.java
@@ -0,0 +1,53 @@
+package io.example.library.api.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import io.example.library.api.AuthorsResource;
+import io.example.library.api.beans.Author;
+
+@ApplicationScoped
+public class AuthorsResourceImpl implements AuthorsResource {
+
+ private Map authorDB = new HashMap<>();
+
+ public AuthorsResourceImpl() {
+ Author author = new Author();
+ author.setId("poe");
+ author.setDob("1809-01-19");
+ author.setName("Edgar Allan Poe");
+ this.authorDB.put("", author);
+ }
+
+ @Override
+ public List getauthors() {
+ List rval = new ArrayList<>();
+ rval.addAll(this.authorDB.values());
+ return rval;
+ }
+
+ @Override
+ public void createAuthor(Author data) {
+ this.authorDB.put(data.getId(), data);
+ }
+
+ @Override
+ public Author getAuthor(String authorId) {
+ return this.authorDB.get(authorId);
+ }
+
+ @Override
+ public void updateAuthor(String authorId, Author data) {
+ this.authorDB.put(authorId, data);
+ }
+
+ @Override
+ public void deleteAuthor(String authorId) {
+ this.authorDB.remove(authorId);
+ }
+
+}
diff --git a/src/main/java/io/example/library/api/impl/BooksResourceImpl.java b/src/main/java/io/example/library/api/impl/BooksResourceImpl.java
new file mode 100644
index 0000000..978c348
--- /dev/null
+++ b/src/main/java/io/example/library/api/impl/BooksResourceImpl.java
@@ -0,0 +1,48 @@
+package io.example.library.api.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import io.example.library.api.BooksResource;
+import io.example.library.api.beans.Book;
+
+@ApplicationScoped
+public class BooksResourceImpl implements BooksResource {
+
+ private Map bookDB = new HashMap<>();
+
+ public BooksResourceImpl() {
+ }
+
+ @Override
+ public List getbooks() {
+ List rval = new ArrayList<>();
+ rval.addAll(this.bookDB.values());
+ return rval;
+ }
+
+ @Override
+ public void createBook(Book data) {
+ this.bookDB.put(data.getDdsn(), data);
+ }
+
+ @Override
+ public Book getBook(String bookId) {
+ return this.bookDB.get(bookId);
+ }
+
+ @Override
+ public void updateBook(String bookId, Book data) {
+ this.bookDB.put(data.getDdsn(), data);
+ }
+
+ @Override
+ public void deleteBook(String bookId) {
+ this.bookDB.remove(bookId);
+ }
+
+}
diff --git a/src/main/resources/META-INF/microprofile-config.properties b/src/main/resources/META-INF/microprofile-config.properties
new file mode 100644
index 0000000..c3fe390
--- /dev/null
+++ b/src/main/resources/META-INF/microprofile-config.properties
@@ -0,0 +1 @@
+mp.openapi.scan.disable=true
\ No newline at end of file
diff --git a/src/main/resources/META-INF/openapi.json b/src/main/resources/META-INF/openapi.json
new file mode 100644
index 0000000..34d5203
--- /dev/null
+++ b/src/main/resources/META-INF/openapi.json
@@ -0,0 +1,308 @@
+{
+ "openapi": "3.0.2",
+ "info": {
+ "title": "Library API",
+ "version": "1.0.0",
+ "description": "A simple API for managing authors and books.",
+ "contact": {
+ "name": "Eric Wittmann",
+ "email": "eric.wittmann@redhat.com"
+ },
+ "license": {
+ "name": "Mozilla 2.0",
+ "url": "https://www.mozilla.org/en-US/MPL/2.0/"
+ }
+ },
+ "paths": {
+ "/authors": {
+ "summary": "Path used to manage the list of authors.",
+ "description": "The REST endpoint/path used to list and create zero or more `Author` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.",
+ "get": {
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Author"
+ }
+ }
+ }
+ },
+ "description": "Successful response - returns an array of `Author` entities."
+ }
+ },
+ "operationId": "getauthors",
+ "summary": "List All authors",
+ "description": "Gets a list of all `Author` entities."
+ },
+ "post": {
+ "requestBody": {
+ "description": "A new `Author` to be created.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Author"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Successful response."
+ }
+ },
+ "operationId": "createAuthor",
+ "summary": "Create a Author",
+ "description": "Creates a new instance of a `Author`."
+ }
+ },
+ "/authors/{authorId}": {
+ "summary": "Path used to manage a single Author.",
+ "description": "The REST endpoint/path used to get, update, and delete single instances of an `Author`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively.",
+ "get": {
+ "tags": [
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Author"
+ }
+ }
+ },
+ "description": "Successful response - returns a single `Author`."
+ },
+ "404": {
+ "$ref": "#/components/responses/NotFound"
+ }
+ },
+ "operationId": "getAuthor",
+ "summary": "Get a Author",
+ "description": "Gets the details of a single instance of a `Author`."
+ },
+ "put": {
+ "requestBody": {
+ "description": "Updated `Author` information.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Author"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "202": {
+ "description": "Successful response."
+ },
+ "404": {
+ "$ref": "#/components/responses/NotFound"
+ }
+ },
+ "operationId": "updateAuthor",
+ "summary": "Update a Author",
+ "description": "Updates an existing `Author`."
+ },
+ "delete": {
+ "responses": {
+ "204": {
+ "description": "Successful response."
+ },
+ "404": {
+ "$ref": "#/components/responses/NotFound"
+ }
+ },
+ "operationId": "deleteAuthor",
+ "summary": "Delete a Author",
+ "description": "Deletes an existing `Author`."
+ },
+ "parameters": [
+ {
+ "name": "authorId",
+ "description": "A unique identifier for a `Author`.",
+ "schema": {
+ "type": "string"
+ },
+ "in": "path",
+ "required": true
+ }
+ ]
+ },
+ "/books": {
+ "summary": "Path used to manage the list of books.",
+ "description": "The REST endpoint/path used to list and create zero or more `Book` entities. This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.",
+ "get": {
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Book"
+ }
+ }
+ }
+ },
+ "description": "Successful response - returns an array of `Book` entities."
+ }
+ },
+ "operationId": "getbooks",
+ "summary": "List All books",
+ "description": "Gets a list of all `Book` entities."
+ },
+ "post": {
+ "requestBody": {
+ "description": "A new `Book` to be created.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Book"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "201": {
+ "description": "Successful response."
+ }
+ },
+ "operationId": "createBook",
+ "summary": "Create a Book",
+ "description": "Creates a new instance of a `Book`."
+ }
+ },
+ "/books/{bookId}": {
+ "summary": "Path used to manage a single Book.",
+ "description": "The REST endpoint/path used to get, update, and delete single instances of an `Book`. This path contains `GET`, `PUT`, and `DELETE` operations used to perform the get, update, and delete tasks, respectively.",
+ "get": {
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Book"
+ }
+ }
+ },
+ "description": "Successful response - returns a single `Book`."
+ }
+ },
+ "operationId": "getBook",
+ "summary": "Get a Book",
+ "description": "Gets the details of a single instance of a `Book`."
+ },
+ "put": {
+ "requestBody": {
+ "description": "Updated `Book` information.",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Book"
+ }
+ }
+ },
+ "required": true
+ },
+ "responses": {
+ "202": {
+ "description": "Successful response."
+ }
+ },
+ "operationId": "updateBook",
+ "summary": "Update a Book",
+ "description": "Updates an existing `Book`."
+ },
+ "delete": {
+ "responses": {
+ "204": {
+ "description": "Successful response."
+ }
+ },
+ "operationId": "deleteBook",
+ "summary": "Delete a Book",
+ "description": "Deletes an existing `Book`."
+ },
+ "parameters": [
+ {
+ "name": "bookId",
+ "description": "A unique identifier for a `Book`.",
+ "schema": {
+ "type": "string"
+ },
+ "in": "path",
+ "required": true
+ }
+ ]
+ }
+ },
+ "components": {
+ "schemas": {
+ "Author": {
+ "title": "Root Type for Author",
+ "description": "The author of a book.",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "dob": {
+ "format": "date",
+ "type": "string"
+ }
+ },
+ "example": {
+ "id": "jk-rowling",
+ "name": "JK Rowling",
+ "dob": "1968-01-01"
+ }
+ },
+ "Book": {
+ "title": "Root Type for Book",
+ "description": "Information about a book.",
+ "type": "object",
+ "properties": {
+ "ddsn": {
+ "type": "string"
+ },
+ "title": {
+ "type": "string"
+ },
+ "author": {
+ "$ref": "#/components/schemas/Author"
+ },
+ "publish-date": {
+ "format": "date",
+ "type": "string"
+ }
+ },
+ "example": {
+ "ddsn": "632.4",
+ "title": "SQL For Dummies",
+ "publish-date": "2001-05-13"
+ }
+ }
+ },
+ "responses": {
+ "NotFound": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ },
+ "description": "Generic response when not found."
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
new file mode 100644
index 0000000..3c1ac56
--- /dev/null
+++ b/src/main/resources/application.properties
@@ -0,0 +1,2 @@
+# Configuration file
+# key = value
\ No newline at end of file