Api REST de CRUD de notas usando Spring Boot e MariaDB
10K+
Api REST de CRUD de notas usando Spring Boot e MariaDB. Projeto feito para estudar Spring Hateoas.
openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost:8080
description: Generated server url
paths:
/v1/notes/{id}:
get:
tags:
- notes-controller
operationId: getNoteById
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/NoteDetailsDto'
put:
tags:
- notes-controller
operationId: updateNote
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NoteForm'
required: true
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/NoteDto'
delete:
tags:
- notes-controller
operationId: deleteNote
parameters:
- name: id
in: path
required: true
schema:
type: integer
format: int64
responses:
"200":
description: OK
/v1/notes:
get:
tags:
- notes-controller
operationId: getAllNotes
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/CollectionModelNoteDto'
post:
tags:
- notes-controller
operationId: createNote
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NoteForm'
required: true
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/NoteDto'
/v1:
get:
tags:
- root-controller
operationId: root
responses:
"200":
description: OK
content:
'*/*':
schema:
$ref: '#/components/schemas/EntryPointDto'
components:
schemas:
NoteForm:
required:
- content
- title
type: object
properties:
title:
type: string
content:
type: string
Link:
type: object
properties:
rel:
type: string
href:
type: string
hreflang:
type: string
media:
type: string
title:
type: string
type:
type: string
deprecation:
type: string
profile:
type: string
name:
type: string
NoteDto:
type: object
properties:
title:
type: string
content:
type: string
links:
type: array
items:
$ref: '#/components/schemas/Link'
EntryPointDto:
type: object
properties:
links:
type: array
items:
$ref: '#/components/schemas/Link'
CollectionModelNoteDto:
type: object
properties:
links:
type: array
items:
$ref: '#/components/schemas/Link'
content:
type: array
items:
$ref: '#/components/schemas/NoteDto'
NoteDetailsDto:
type: object
properties:
title:
type: string
content:
type: string
createdAt:
type: string
format: date-time
updatedAt:
type: string
format: date-time
links:
type: array
items:
$ref: '#/components/schemas/Link'
| Name | Located in | Description | Required | Schema |
|---|---|---|---|---|
| id | path | Yes | long |
| Code | Description |
|---|---|
| 200 | OK |
| Name | Located in | Description | Required | Schema |
|---|---|---|---|---|
| id | path | Yes | long |
| Code | Description |
|---|---|
| 200 | OK |
| Name | Located in | Description | Required | Schema |
|---|---|---|---|---|
| id | path | Yes | long |
| Code | Description |
|---|---|
| 200 | OK |
| Code | Description |
|---|---|
| 200 | OK |
| Code | Description |
|---|---|
| 200 | OK |
| Code | Description |
|---|---|
| 200 | OK |
Coleção para testar os endpoints da aplicação
Criar arquivo docker-compose.yaml:
version: "3.7"
services:
mariadb:
container_name: notes_db
image: mariadb:10.7
restart: unless-stopped
networks:
- easy-notes-network
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_PASSWORD: root
MYSQL_USER: root
MYSQL_DATABASE: notes-api
networks:
easy-notes-network:
driver: bridge
Rodar os seguintes comados
# Subir container do MariaDB
docker-compose up -d
# Baixar a imagem
docker pull gustosilva/easy-notes-api:latest
# Gerar o containter
docker run --network easy-notes_easy-notes-network \
--env DB_USER=root \
--env DB_PASSWORD=root \
-p 8080:8080 gustosilva/easy-notes-api:latest
Projeto feito usando Java 1.8 e Maven 3.8 como ferramenta de build.
Content type
Image
Digest
sha256:ce4c16c4c…
Size
112.5 MB
Last updated
over 3 years ago
docker pull gustosilva/easy-notes-api