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 smithy/model/article/article-apis.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
$version: "2"

namespace shopping.inandout.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.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 smithy/model/article/article-io.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
$version: "2"

namespace shopping.inandout.article

use shopping.inandout#BrandIdMixin
use shopping.inandout#PositiveDouble
use shopping.inandout#UUID
use shopping.inandout.product#CreateProductInput
use shopping.inandout.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 smithy/model/article/article-types.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$version: "2"

namespace shopping.inandout.article

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

@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] {}
76 changes: 76 additions & 0 deletions smithy/model/brand/brand-apis.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
$version: "2"

namespace shopping.inandout.brand

use shopping.inandout#DeleteRestrictedError
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 Brand {
identifiers: {
brandId: UUID
}
properties: {
name: ResourceName
logoUrl: ImageUrl
createdAt: Timestamp
updatedAt: Timestamp
}
create: CreateBrand
read: GetBrand
update: UpdateBrand
delete: DeleteBrand
}

@http(method: "POST", uri: "/brands")
operation CreateBrand {
input: CreateBrandInput
output: CreateBrandOutput
errors: [
InvalidInputError
ResourceAlreadyExistsError
InternalServerError
]
}

@readonly
@http(method: "GET", uri: "/brands/{brandId}")
operation GetBrand {
input: GetBrandInput
output: GetBrandOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@http(method: "PATCH", uri: "/brands/{brandId}")
operation UpdateBrand {
input: UpdateBrandInput
output: UpdateBrandOutput
errors: [
InvalidInputError
ResourceNotFoundError
InternalServerError
]
}

@idempotent
@http(method: "DELETE", uri: "/brands/{brandId}")
@documentation("Restricted cascading operation, references for stores and articles should NOT exist")
operation DeleteBrand {
input: DeleteBrandInput
output: DeleteBrandOutput
errors: [
InvalidInputError
ResourceNotFoundError
DeleteRestrictedError
InternalServerError
]
}
42 changes: 42 additions & 0 deletions smithy/model/brand/brand-io.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
$version: "2"

namespace shopping.inandout.brand

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

structure CreateBrandInput with [BrandInputMixin] {
@required
name: ResourceName
}

structure CreateBrandOutput {
@required
brandId: UUID
}

structure GetBrandInput {
@required
@httpLabel
brandId: UUID
}

structure GetBrandOutput with [BrandOutputMixin] {}

structure UpdateBrandInput with [BrandInputMixin] {
@required
@httpLabel
brandId: UUID

name: ResourceName
}

structure UpdateBrandOutput with [BrandOutputMixin] {}

structure DeleteBrandInput {
@required
@httpLabel
brandId: UUID
}

structure DeleteBrandOutput {}
32 changes: 32 additions & 0 deletions smithy/model/brand/brand-types.smithy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$version: "2"

namespace shopping.inandout.brand

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

@mixin
structure BrandMixin {
logoUrl: ImageUrl
}

@mixin
structure BrandInputMixin with [BrandMixin] {}

@mixin
@references([
{
resource: Brand
}
])
structure BrandOutputMixin with [AuditMetadata, BrandMixin] {
@required
brandId: UUID

@required
name: ResourceName
}

structure BrandSummary with [BrandOutputMixin] {}
Loading