Skip to content

eriawan06/go-test-sagara

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Test Case Sagara

Version 1.0

Path Table

Method Path Description
POST /auth/login Login
POST /auth/register User Registration
GET /api/users List All Users
GET /api/users/{userId} Get User By Id
GET /api/products List All Products
POST /api/products Create Product
GET /api/products/{productId} Get Product By Id
PUT /api/products/{productId} Update Product By Id
DELETE /api/products/{productId} Delete Product
POST /api/products/image/upload Upload Product Image
GET /api/products/image/{filename} Get Product Image
POST /api/refresh-token Refresh Token

Reference Table

Name Path Description
model.LoginBody #/components/schemas/model.LoginBody
model.LoginResponse #/components/schemas/model.LoginResponse
model.Tokens #/components/schemas/model.Tokens
model.User #/components/schemas/model.User
model.UserBody #/components/schemas/model.UserBody
model.Product #/components/schemas/model.Product
model.ProductBody #/components/schemas/model.ProductBody

Path Details


[POST]/auth/login

  • Summary
    Login

  • Description
    Login

RequestBody

  • application/json
{
  username: string
  password: string
}

Responses

  • 200 Login Success

application/json

{
  code: number
  status: string
  data: {
    tokens: {
      access_token: string
      refresh_token: string
    }
    user: {
      id: number
      fullname: string
      username: string
      created_at: string
      updated_at: string
    }
  }
}

[POST]/auth/register

  • Summary
    User Registration

  • Description
    User Registration

RequestBody

  • application/json
{
  fullname: string
  username: string
  password: string
}

Responses

  • 200 Registration Success

application/json

{
  code: number
  status: string
  data: {
    id: number
    fullname: string
    username: string
    created_at: string
    updated_at: string
  }
}

[GET]/api/users

  • Summary
    List All Users

  • Description
    List All Users

Headers

Authorization: string

Responses

  • 200 Success get all users

application/json

{
  code: number
  status: string
  data: [
    {
        id: number
        fullname: string
        username: string
        created_at: string
        updated_at: string
    }
  ]
}

[GET]/api/users/{userId}

  • Summary
    Get User By Id

  • Description
    Get User By Id

Headers

Authorization: string

Responses

  • 200 Success get user by id

application/json

{
  code: number
  status: string
  data: {
    id: number
    fullname: string
    username: string
    created_at: string
    updated_at: string
  }
}

[GET]/api/products

  • Summary
    List All Products

  • Description
    List All Products

Headers

Authorization: string

Responses

  • 200 Success get all products

application/json

{
  code: number
  status: string
  data: [
    {
        id: number
        name: string
        description: string
        price: number
        image: string
        created_at: string
        updated_at: string
    }
  ]
}

[POST]/api/products

  • Summary
    Create Product

  • Description
    Create Product

Headers

Authorization: string

RequestBody

  • application/json
{
  name: string
  description: string
  price: number
  image: string
}

Responses

  • 200 Success create product

application/json

{
  code: number
  status: string
  data: {
    id: number
    name: string
    description: string
    price: number
    image: string
    created_at: string
    updated_at: string
  }
}

[GET]/api/products/{productId}

  • Summary
    Get Product By Id

  • Description
    Get Product By Id

Headers

Authorization: string

Responses

  • 200 Success get product by id

application/json

{
  code: number
  status: string
  data: {
    id: number
    name: string
    description: string
    price: number
    image: string
    created_at: string
    updated_at: string
  }
}

[PUT]/api/products/{productId}

  • Summary
    Update Product By Id

  • Description
    Update Product By Id

Headers

Authorization: string

RequestBody

  • application/json
{
  name: string
  description: string
  price: number
  image: string
}

Responses

  • 200 Success update product by id

application/json

{
  code: number
  status: string
  data: {
    id: number
    name: string
    description: string
    price: number
    image: string
    created_at: string
    updated_at: string
  }
}

[DELETE]/api/products/{productId}

  • Summary
    Delete Product

  • Description
    Delete Product

Headers

Authorization: string

Responses

  • 200 Success delete product

application/json

{
  code: number
  status: string
}

[POST]/api/products/image/upload

  • Summary
    Upload Product Image

  • Description
    Upload Product Image

Headers

Authorization: string

RequestBody

  • multipart/form-data
{
  file: string
  filename: string
}

Responses

  • 200 Success upload product image

application/json

{
  code: number
  status: string
  data: {
    url: string
  }
}

[GET]/api/products/image/{filename}

  • Summary
    Get Product Image

  • Description
    Get Product Image

Headers

Authorization: string

Responses

  • 200 Success get product image

image/jpeg

{
  "type": "string",
  "format": "binary",
  "description": "Image File"
}

[POST]/api/refresh-token

  • Summary
    Refresh Token

  • Description
    Refresh Token

Headers

Authorization: string

Responses

  • 200 Success refresh token

application/json

{
  code: number
  status: string
  data: {
    access_token: string
    refresh_token: string
  }
}

References

#/components/schemas/model.LoginBody

{
  username: string
  password: string
}

#/components/schemas/model.LoginResponse

{
  tokens: {
    access_token: string
    refresh_token: string
  }
  user: {
    id: number
    fullname: string
    username: string
    created_at: string
    updated_at: string
  }
}

#/components/schemas/model.Tokens

{
  access_token: string
  refresh_token: string
}

#/components/schemas/model.User

{
  id: number
  fullname: string
  username: string
  created_at: string
  updated_at: string
}

#/components/schemas/model.UserBody

{
  fullname: string
  username: string
  password: string
}

#/components/schemas/model.Product

{
  id: number
  name: string
  description: string
  price: number
  image: string
  created_at: string
  updated_at: string
}

#/components/schemas/model.ProductBody

{
  name: string
  description: string
  price: number
  image: string
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages