Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions spec/smithy/model/catalog/article/article-apis.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
$version: "2"

namespace shopping.inandout.catalog.article

use shopping.inandout#DeleteRestrictedError
use shopping.inandout#InternalServerError
use shopping.inandout#InvalidInputError
use shopping.inandout#PositiveDouble
use shopping.inandout#ResourceAlreadyExistsError
use shopping.inandout#ResourceNotFoundError
use shopping.inandout#UUID
use shopping.inandout.catalog.product#ProductSummary

resource Article {
identifiers: {
articleId: UUID
}
properties: {
productSummary: ProductSummary
brandId: UUID
price: PositiveDouble
currency: String
createdAt: Timestamp
updatedAt: Timestamp
}
create: CreateArticle
read: GetArticle
update: UpdateArticle
delete: DeleteArticle
}

@http(method: "POST", uri: "/brands/{brandId}/articles")
operation CreateArticle {
input: CreateArticleInput
output: CreateArticleOutput
errors: [
InvalidInputError
ResourceAlreadyExistsError
InternalServerError
]
}

@readonly
@http(method: "GET", uri: "/brands/{brandId}/articles/{articleId}")
operation GetArticle {
input: GetArticleInput
output: GetArticleOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@http(method: "PATCH", uri: "/brands/{brandId}/articles/{articleId}")
operation UpdateArticle {
input: UpdateArticleInput
output: UpdateArticleOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@idempotent
@http(method: "DELETE", uri: "/brands/{brandId}/articles/{articleId}")
@documentation("Restricted cascading operation, references for stands should NOT exist")
operation DeleteArticle {
input: DeleteArticleInput
output: DeleteArticleOutput
errors: [
InvalidInputError
ResourceNotFoundError
DeleteRestrictedError
InternalServerError
]
}
60 changes: 60 additions & 0 deletions spec/smithy/model/catalog/article/article-io.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
$version: "2"

namespace shopping.inandout.catalog.article

use shopping.inandout#BrandIdMixin
use shopping.inandout#PositiveDouble
use shopping.inandout#UUID
use shopping.inandout.catalog.product#CreateProductInput
use shopping.inandout.catalog.product#Product

@references([
{
resource: Product
}
])
structure CreateArticleInput with [BrandIdMixin, ArticleInputMixin] {
@required
price: PositiveDouble

// Clients must choose between providing a product id/details.
// Not none, not both, one field must be filled.
@notProperty
@documentation("Existing product referenced in a new article")
productId: UUID

@notProperty
@documentation("Creates a new product")
createProductInput: CreateProductInput
}

structure CreateArticleOutput {
@required
articleId: UUID
}

structure GetArticleInput with [BrandIdMixin] {
@required
@httpLabel
articleId: UUID
}

structure GetArticleOutput with [ArticleOutputMixin] {}

structure UpdateArticleInput with [BrandIdMixin, ArticleInputMixin] {
@required
@httpLabel
articleId: UUID

price: PositiveDouble
}

structure UpdateArticleOutput with [ArticleOutputMixin] {}

structure DeleteArticleInput with [BrandIdMixin] {
@required
@httpLabel
articleId: UUID
}

structure DeleteArticleOutput {}
42 changes: 42 additions & 0 deletions spec/smithy/model/catalog/article/article-types.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$version: "2"

namespace shopping.inandout.catalog.article

use shopping.inandout#AuditMetadata
use shopping.inandout#PositiveDouble
use shopping.inandout#UUID
use shopping.inandout.catalog.product#ProductSummary
use shopping.inandout.outlet.brand#Brand

@mixin
structure ArticleMixin {
currency: String
}

@mixin
structure ArticleInputMixin with [ArticleMixin] {}

@mixin
@references([
{
resource: Brand
}
{
resource: Article
}
])
structure ArticleOutputMixin with [AuditMetadata, ArticleMixin] {
@required
brandId: UUID

@required
articleId: UUID

@required
productSummary: ProductSummary

@required
price: PositiveDouble
}

structure ArticleSummary with [ArticleOutputMixin] {}
81 changes: 81 additions & 0 deletions spec/smithy/model/catalog/product/product-apis.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
$version: "2"

namespace shopping.inandout.catalog.product

use shopping.inandout#DeleteRestrictedError
use shopping.inandout#Description
use shopping.inandout#ImageUrl
use shopping.inandout#InternalServerError
use shopping.inandout#InvalidInputError
use shopping.inandout#ResourceAlreadyExistsError
use shopping.inandout#ResourceName
use shopping.inandout#ResourceNotFoundError
use shopping.inandout#UUID

resource Product {
identifiers: {
productId: UUID
}
properties: {
name: ResourceName
subcategory: ResourceName
category: ResourceName
vendor: ResourceName
imageUrl: ImageUrl
description: Description
createdAt: Timestamp
updatedAt: Timestamp
}
create: CreateProduct
read: GetProduct
update: UpdateProduct
delete: DeleteProduct
}

@http(method: "POST", uri: "/products")
operation CreateProduct {
input: CreateProductInput
output: CreateProductOutput
errors: [
InvalidInputError
ResourceAlreadyExistsError
InternalServerError
]
}

@readonly
@http(method: "GET", uri: "/products/{productId}")
operation GetProduct {
input: GetProductInput
output: GetProductOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@http(method: "PATCH", uri: "/products/{productId}")
operation UpdateProduct {
input: UpdateProductInput
output: UpdateProductOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@idempotent
@http(method: "DELETE", uri: "/products/{productId}")
@documentation("Restricted cascading operation, references for articles should NOT exist")
operation DeleteProduct {
input: DeleteProductInput
output: DeleteProductOutput
errors: [
InvalidInputError
ResourceNotFoundError
DeleteRestrictedError
InternalServerError
]
}
52 changes: 52 additions & 0 deletions spec/smithy/model/catalog/product/product-io.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
$version: "2"

namespace shopping.inandout.catalog.product

use shopping.inandout#ResourceName
use shopping.inandout#UUID

structure CreateProductInput with [ProductInputMixin] {
@required
name: ResourceName

@required
subcategory: ResourceName

@required
category: ResourceName
}

structure CreateProductOutput {
@required
productId: UUID
}

structure GetProductInput {
@required
@httpLabel
productId: UUID
}

structure GetProductOutput with [ProductOutputMixin] {}

structure UpdateProductInput with [ProductInputMixin] {
@required
@httpLabel
productId: UUID

name: ResourceName

subcategory: ResourceName

category: ResourceName
}

structure UpdateProductOutput with [ProductOutputMixin] {}

structure DeleteProductInput {
@required
@httpLabel
productId: UUID
}

structure DeleteProductOutput {}
41 changes: 41 additions & 0 deletions spec/smithy/model/catalog/product/product-types.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$version: "2"

namespace shopping.inandout.catalog.product

use shopping.inandout#AuditMetadata
use shopping.inandout#Description
use shopping.inandout#ImageUrl
use shopping.inandout#ResourceName
use shopping.inandout#UUID

@mixin
structure ProductMixin {
vendor: ResourceName
imageUrl: ImageUrl
description: Description
}

@mixin
structure ProductInputMixin with [ProductMixin] {}

@mixin
@references([
{
resource: Product
}
])
structure ProductOutputMixin with [AuditMetadata, ProductMixin] {
@required
productId: UUID

@required
name: ResourceName

@required
subcategory: ResourceName

@required
category: ResourceName
}

structure ProductSummary with [ProductOutputMixin] {}
Loading