product-catalog API (1.0.0-SNAPSHOT)

Download OpenAPI specification:

Product V1

Basic memory-based API for M1 introduction

Get all products

Returns the full list from memory

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create product

Adds a product if SKU is unique

Request Body schema: application/json
required
sku
string
name
string
price
number
stock
integer <int32>
inStock
boolean

Responses

Request samples

Content type
application/json
{
  • "sku": "string",
  • "name": "string",
  • "price": 0,
  • "stock": 0,
  • "inStock": true
}

Response samples

Content type
application/json
null

Product V2

Memory-based API with Path Params and Exceptions

List all products

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create product

Request Body schema: application/json
required
sku
string
name
string
price
number
stock
integer <int32>
inStock
boolean

Responses

Request samples

Content type
application/json
{
  • "sku": "string",
  • "name": "string",
  • "price": 0,
  • "stock": 0,
  • "inStock": true
}

Get product by SKU

path Parameters
sku
required
string

Product SKU

Responses

Response samples

Content type
application/json
{
  • "sku": "string",
  • "name": "string",
  • "price": 0,
  • "stock": 0,
  • "inStock": true
}

Delete product

path Parameters
sku
required
string

Responses

Product V3

Service-based API with Dependency Injection

Get all products

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create product

Request Body schema: application/json
required
id
integer <int64>
sku
string
name
string
price
number
stock
integer <int32>

Responses

Request samples

Content type
application/json
{
  • "id": 0,
  • "sku": "string",
  • "name": "string",
  • "price": 0,
  • "stock": 0
}

Get product by SKU

path Parameters
sku
required
string

Product SKU

Responses

Response samples

Content type
application/json
{
  • "id": 0,
  • "sku": "string",
  • "name": "string",
  • "price": 0,
  • "stock": 0
}

Delete product

path Parameters
sku
required
string

Responses

Product V4

API using DTOs to encapsulate the Domain model

Get all products (DTO)

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create product (DTO)

Request Body schema: application/json
required
sku
required
string\S

Unique SKU of the product

name
required
string\S

Name of the product

price
required
number >= 0

Unit price

stock
integer <int32> >= 0

Initial stock quantity

Responses

Request samples

Content type
application/json
{
  • "sku": "SKU123",
  • "name": "Office Chair",
  • "price": 50,
  • "stock": 10
}

Get product by SKU (DTO)

path Parameters
sku
required
string

Product SKU

Responses

Response samples

Content type
application/json
{
  • "sku": "SKU123",
  • "name": "Office Chair",
  • "price": 50,
  • "stock": 10
}

Delete product

path Parameters
sku
required
string

Responses

Product V5

Validated and documented production-ready API

Get all products

Returns a list of all products in the catalog

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Create a new product

Validates input and persists a new product

Request Body schema: application/json
required
sku
required
string\S

Unique SKU of the product

name
required
string\S

Name of the product

price
required
number >= 0

Unit price

stock
integer <int32> >= 0

Initial stock quantity

Responses

Request samples

Content type
application/json
{
  • "sku": "SKU123",
  • "name": "Office Chair",
  • "price": 50,
  • "stock": 10
}

Response samples

Content type
application/json
{
  • "sku": "SKU123",
  • "name": "Office Chair",
  • "price": 50,
  • "stock": 10
}

Get product by SKU

Finds a specific product using its unique SKU

path Parameters
sku
required
string
Examples:

    The SKU of the product

    Responses

    Response samples

    Content type
    application/json
    {
    • "sku": "SKU123",
    • "name": "Office Chair",
    • "price": 50,
    • "stock": 10
    }

    Delete a product

    Removes a product from the database by its SKU

    path Parameters
    sku
    required
    string

    The SKU of the product to delete

    Responses