Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Created March 8, 2025 00:05
Show Gist options
  • Save nasrulhazim/3930b949d9908dccc61a3a7b61c51c17 to your computer and use it in GitHub Desktop.
Save nasrulhazim/3930b949d9908dccc61a3a7b61c51c17 to your computer and use it in GitHub Desktop.
Laravel Bootcamp Chirp OpenAPI Specification
openapi: 3.1.0
info:
title: Chirps API
description: |-
Welcome to the Laravel Bootcamp! In this guide we will walk through building a modern Laravel application from scratch. To explore the framework, we'll build a microblogging platform called Chirper.
termsOfService: http://chirps.com/terms/
contact:
email: [email protected]
license:
name: MIT
url: https://opensource.org/license/mit
version: 1.0.0
servers:
- url: http://127.0.0.1:3000
description: Mock
- url: http://127.0.0.1:8000/api
description: Development
- url: https://api.chirps.com
description: Production
tags:
- name: Auth
description: Handle login, logout, register...
- name: Chirp
description: Chirping...
paths:
/login:
post:
tags:
- Auth
description: Logint to Chirpt
operationId: login
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
email:
type: string
password:
type: string
required:
- email
- password
responses:
'200':
description: Successfully logged in.
content:
application/json:
schema:
$ref: '#/components/schemas/AccessToken'
'401':
description: Unauthentcated access
content:
application/json:
schema:
$ref: '#/components/schemas/InvalidCredential'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/register:
post:
tags:
- Auth
description: Register a new user
operationId: register
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
email:
type: string
password:
type: string
password_confirmation:
type: string
required:
- name
- email
- password
- password_confirmation
responses:
'200':
description: User registered successfully
content:
application/json:
schema:
type: object
properties:
access_token:
type: string
token_type:
type: string
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/logout:
post:
tags:
- Auth
description: Logout the current user
operationId: logout
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
security:
- bearerAuth: []
responses:
'200':
description: User logged out successfully
/chirps:
get:
tags:
- Chirp
description: Return list of chirps
operationId: getChirpList
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
security:
- bearerAuth: []
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Chirp'
post:
tags:
- Chirp
description: Create new chirp
operationId: createNewChirp
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
security:
- bearerAuth: []
requestBody:
description: Create a new chirp
content:
application/json:
schema:
$ref: '#/components/schemas/ChirpMessage'
required: true
responses:
'201':
description: Successful create new chirp
content:
application/json:
schema:
$ref: '#/components/schemas/Chirp'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
/chirps/{chirp}:
delete:
tags:
- Chirp
description: Delete a of chirp owned by user
operationId: deleteChirpById
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
- name: chirp
in: path
description: ID of Chirp
required: true
schema:
type: integer
format: int64
security:
- bearerAuth: []
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponseMessage'
get:
tags:
- Chirp
description: Return list of chirps
operationId: getChirpById
security:
- bearerAuth: []
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
- name: chirp
in: path
description: ID of Chirp
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Chirp'
put:
tags:
- Chirp
summary: Update an existing chirp
description: Update an existing chirp by Id
operationId: updateChirp
security:
- bearerAuth: []
parameters:
- in: header
name: Accept
required: true
schema:
type: string
example: application/json
- name: chirp
in: path
description: ID of Chirp
required: true
schema:
type: integer
format: int64
requestBody:
description: Update an existent chirp
content:
application/json:
schema:
$ref: '#/components/schemas/ChirpMessage'
required: true
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Chirp'
'400':
description: Invalid ID supplied
'404':
description: Chirp not found
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
ApiResponseMessage:
type: object
properties:
message:
type: string
InvalidCredential:
type: object
properties:
message:
type: string
AccessToken:
type: object
properties:
access_token:
type: string
examples: [1234567890wertyuioxcvbnjmasdfghjk]
token_type:
type: string
ChirpMessage:
type: object
properties:
message:
type: string
examples: [lorem ipsum]
Chirp:
required:
- message
type: object
properties:
id:
type: integer
format: int64
examples: [10]
user_id:
type: integer
format: int64
examples: [10]
message:
type: string
examples: [lorem ipsum]
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
ValidationError:
type: object
properties:
success:
type: boolean
errors:
type: object
additionalProperties:
type: array
items:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment