Skip to content
Snippets Groups Projects
Commit 0d298182 authored by Yusuf Akgül's avatar Yusuf Akgül :hatching_chick:
Browse files

Merge branch 'swaggerDocWithChanges' into 'main'

docs

See merge request !43
parents 1e04ab8f 5a2b3e29
No related branches found
No related tags found
1 merge request!43docs
Pipeline #39804 passed
import { getApiDocs } from '@/lib/swagger'
import ReactSwagger from './react-swagger'
export default async function IndexPage() {
const spec = await getApiDocs()
return (
<section className="container">
<ReactSwagger spec={spec} />
</section>
)
}
\ No newline at end of file
'use client'
import SwaggerUI from 'swagger-ui-react'
import 'swagger-ui-react/swagger-ui.css'
type Props = {
spec: Record<string, any>,
}
function ReactSwagger({ spec }: Props) {
return <SwaggerUI spec={spec} />
}
export default ReactSwagger
\ No newline at end of file
......@@ -5,6 +5,21 @@ import { IPlatformCategrory } from "@/types/igdb-types"
import { NextRequest, NextResponse } from "next/server"
/**
* @swagger
* /api/games:
* get:
* description: Get Games through external API
* content:
* application/json:
* schema:
* responses:
* 200:
* description: list of games
* 500:
* description: error
*/
export async function GET(req: NextRequest) {
const p = req.nextUrl.searchParams
try {
......
......@@ -3,6 +3,33 @@ import { z } from "zod"
import { db } from "@/lib/db"
/**
* @swagger
* /api/gweets/{id}:
* get:
* description: Gives back a List of Gweets
* parameters:
* - name: id
* in: path
* description: ID of Gweet that needs to be fetched
* required: true
* schema:
* type: integer
* format: int64
* content:
* application/json:
* schema:
* responses:
* 200:
* description: fetched gweets!
* 400:
* description: Invalid request body!
* 404:
* description: Gweet not found!
* 500:
* description: Error
*/
export async function GET(request: Request, { params }: { params: { id: string } }) {
const { id } = params
......
......@@ -3,6 +3,36 @@ import { z } from "zod"
import { db } from "@/lib/db"
/**
* @swagger
* /api/gweets/likes:
* get:
* description: Gets back likeData
* content:
* application/json:
* schema:
* responses:
* 200:
* description: fetched like!
* 500:
* description: Error
*
* post:
* description: Creates Gweet
* responses:
* 200:
* description: Gweet unliked!
* 201:
* description: Gweet liked!
* 401:
* description: Unauthorized
* 404:
* description: Invalid request body !
* 500:
* description: Error
*
*/
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const user_id = searchParams.get("user_id") || undefined
......
......@@ -3,6 +3,24 @@ import { z } from "zod"
import { db } from "@/lib/db"
/**
* @swagger
* /api/gweets/regweets:
* post:
* description: Creates Regweet
* responses:
* 200:
* description: Deleted gweet regweet!
* 201:
* description: Gweet regweeted!
* 400:
* description: Invalid request body
* 401:
* description: Unauthorized
* 500:
* description: Error
*/
export async function POST(request: Request) {
const { gweet_id, user_id } = await request.json()
......
......@@ -4,6 +4,41 @@ import { z } from "zod"
import { db } from "@/lib/db"
import { utapi } from "uploadthing/server"
/**
* @swagger
* /api/gweets:
* get:
* description: Gives back a List of Gweets
* content:
* application/json:
* schema:
* responses:
* 200:
* description: fetched gweets!
* 500:
* description: Error
*
* post:
* description: Creates Gweet
* responses:
* 200:
* description: Gweet created!
* 401:
* description: Unauthorized
* 500:
* description: Error
*
* delete:
* description: Deletes Gweet
* responses:
* 200:
* description: deleted!
* 401:
* description: Unauthorized
* 500:
* description: Error
*/
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
......
......@@ -3,6 +3,32 @@ import { z } from "zod"
import { db } from "@/lib/db"
/**
* @swagger
* /api/hashtags:
* get:
* description: Gives back a List of Hashtags
* content:
* application/json:
* schema:
* responses:
* 200:
* description: fetched hashtags!
* 500:
* description: Error
*
* post:
* description: Creates Hashtag
* responses:
* 200:
* description: Hashtag created!
* 401:
* description: Unauthorized
* 500:
* description: Error
*
*/
export async function GET() {
try {
const hashtags = await db.hashtag.findMany({
......
......@@ -3,6 +3,22 @@ import { hash } from 'bcrypt'
import { NextResponse } from 'next/server'
import { normalize } from 'normalize-diacritics'
/**
* @swagger
* /api/signup:
*
* post:
* description: Creates Account after Email was verified
* responses:
* 200:
* description: Verification sent!
* 422:
* description: Email already used
* 500:
* description: Error!
*
*/
export async function POST(req: Request) {
try {
const { username, email, password } = await req.json()
......
......@@ -3,6 +3,42 @@ import { getCurrentUser } from "@/lib/session"
import { NextResponse } from "next/server"
import { z } from "zod"
/**
* @swagger
* /api/users/follow:
* get:
* description: Get Followers for signed in User
* responses:
* 200:
* description: fetched follows!
* 500:
* description: Error
*
* put:
* description: Creates Following Record from one User to another
* requestBody:
* content:
* application/json:
* schema: # Request body contents
* type: object
* properties:
* follwerid:
* type: string
* followingid:
* type: string
* example: # Sample object
* follwerid:: 10
* followingid:: 12
* responses:
* 200:
* description: Follow handled!
* 401:
* description: Unauthorized
* 500:
* description: Error
*
*/
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const username = searchParams.get("userId") || undefined
......
......@@ -4,6 +4,20 @@ import { User } from "@prisma/client"
import { revalidatePath } from "next/cache"
import { NextRequest, NextResponse } from "next/server"
/**
* @swagger
* /api/users/gamelists:
* put:
* description: Changes gamelists of a user
* id in body must match userid
* responses:
* 200:
* description: Request handled!
* 401:
* description: Unauthorized
*
*/
export async function PUT(req: NextRequest) {
const sessionUser = await getCurrentUser()
......
import { createSwaggerSpec } from 'next-swagger-doc'
export const getApiDocs = async () => {
const spec = createSwaggerSpec({
apiFolder: 'app/api', // define api folder under app folder
definition: {
openapi: '3.0.0',
info: {
title: 'GameUnity Api Documentation',
version: '1.0',
},
components: {
securitySchemes: {
BearerAuth: {
type: 'http',
scheme: 'bearer',
bearerFormat: 'JWT',
},
},
},
security: [],
},
})
return spec
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment