diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4080c6f --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Eclipse +.classpath +.project +.settings/ + +# Intellij +.idea/ +*.iml +*.iws + +# VSCode +bin/ + +# Mac +.DS_Store + +# Smithy +.smithy.lsp.log + +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build/ diff --git a/README.md b/README.md index 27287f5..688c703 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ # InAndOut-API-Modelling -Module used to create clients (standard data types and classes) for our services and interfaces + +Complete API model for our system. + +References: + +- https://docs.google.com/document/d/1HnRcB2SaG4f4QodOaaYZT4r4GYhibqBzA8wdl2zpID0/edit?tab=t.h8qwaqvashle +- https://openapi-converter.com/json-to-yaml +- https://editor.swagger.io/ +- https://smithy.io/2.0/languages/java/client/generating-clients.html +- https://smithy.io/2.0/guides/using-code-generation/generating-a-client.html diff --git a/smithy-build.json b/smithy-build.json new file mode 100644 index 0000000..e326f5a --- /dev/null +++ b/smithy-build.json @@ -0,0 +1,42 @@ +{ + "version": "1.0", + "outputDirectory": "build/", + "sources": ["smithy/model/"], + "maven": { + "dependencies": [ + "software.amazon.smithy:smithy-aws-traits:1.68.0", + "software.amazon.smithy:smithy-openapi:1.68.0", + "software.amazon.smithy:smithy-linters:1.68.0", + "software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.45.0", + "software.amazon.smithy.java:client-codegen:0.0.3", + "software.amazon.smithy.java:client-core:0.0.3" + ] + }, + "projections": { + "openapi-spec": { + "plugins": { + "openapi": { + "service": "com.shopping.inandout#InAndOut", + "protocol": "aws.protocols#restJson1", + "version": "3.1.0" + } + } + }, + "java-client": { + "plugins": { + "java-client-codegen": { + "service": "com.shopping.inandout#InAndOut", + "namespace": "com.shopping.inandout" + } + } + }, + "typescript-client": { + "plugins": { + "typescript-codegen": { + "package": "@inandout/client", + "packageVersion": "0.0.1" + } + } + } + } +} diff --git a/smithy/model/common.smithy b/smithy/model/common.smithy new file mode 100644 index 0000000..90426d1 --- /dev/null +++ b/smithy/model/common.smithy @@ -0,0 +1,11 @@ +$version: "2" + +namespace com.shopping.inandout + +@pattern("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$") +@length(min: 36, max: 36) +string UUID + +list UUIDList { + member: UUID +} diff --git a/smithy/model/errors.smithy b/smithy/model/errors.smithy new file mode 100644 index 0000000..ebf0291 --- /dev/null +++ b/smithy/model/errors.smithy @@ -0,0 +1,38 @@ +$version: "2" + +namespace com.shopping.inandout + +@error("client") +@httpError(400) +structure InvalidInputError { + @required + message: String +} + +@error("client") +@httpError(404) +structure ResourceNotFoundError { + @required + message: String +} + +@error("client") +@httpError(409) +structure ResourceAlreadyExistsError { + @required + message: String +} + +@error("client") +@httpError(409) +structure DeleteRestrictedError { + @required + message: String +} + +@error("server") +@httpError(500) +structure InternalServerError { + @required + message: String +} diff --git a/smithy/model/main.smithy b/smithy/model/main.smithy new file mode 100644 index 0000000..adae545 --- /dev/null +++ b/smithy/model/main.smithy @@ -0,0 +1,14 @@ +$version: "2" + +namespace com.shopping.inandout + +use com.shopping.inandout.tsp#FindTspSolution +use aws.protocols#restJson1 + +@restJson1 +service InAndOut { + version: "2026-04-01" + operations: [ + FindTspSolution + ] +} diff --git a/smithy/model/tsp/tsp-apis.smithy b/smithy/model/tsp/tsp-apis.smithy new file mode 100644 index 0000000..ee0eb1b --- /dev/null +++ b/smithy/model/tsp/tsp-apis.smithy @@ -0,0 +1,19 @@ +$version: "2" + +namespace com.shopping.inandout.tsp + +use com.shopping.inandout#InternalServerError +use com.shopping.inandout#InvalidInputError +use com.shopping.inandout#ResourceNotFoundError + +@http(method: "POST", uri: "/tsp") +@documentation("Travelling salesman problem solution creation/retrieval operation") +operation FindTspSolution { + input: FindTspSolutionInput + output: FindTspSolutionOutput + errors: [ + InvalidInputError + ResourceNotFoundError + InternalServerError + ] +} diff --git a/smithy/model/tsp/tsp-io.smithy b/smithy/model/tsp/tsp-io.smithy new file mode 100644 index 0000000..24c4b15 --- /dev/null +++ b/smithy/model/tsp/tsp-io.smithy @@ -0,0 +1,15 @@ +$version: "2" + +namespace com.shopping.inandout.tsp + +use com.shopping.inandout#UUIDList + +structure FindTspSolutionInput { + @required + standIdList: UUIDList +} + +structure FindTspSolutionOutput { + @required + solutionList: SolutionList +} diff --git a/smithy/model/tsp/tsp-types.smithy b/smithy/model/tsp/tsp-types.smithy new file mode 100644 index 0000000..214f970 --- /dev/null +++ b/smithy/model/tsp/tsp-types.smithy @@ -0,0 +1,16 @@ +$version: "2" + +namespace com.shopping.inandout.tsp + +use com.shopping.inandout#UUIDList + +@documentation("Optimal market route") +structure Solution { + @required + @documentation("Ordered location list of the selected articles") + nodeIdList: UUIDList +} + +list SolutionList { + member: Solution +}