From 1c6f0a75fd3243af6b36150682976b5ad418e709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Skj=C3=B8lberg?= Date: Sun, 1 Dec 2024 15:06:05 +0100 Subject: [PATCH] Add openapi support --- openapi/README.md | 2 + openapi/openapi-client/pom.xml | 121 ++++++++++++ openapi/openapi-model/pom.xml | 118 +++++++++++ .../src/main/resources/3d-api.yaml | 183 ++++++++++++++++++ openapi/openapi-server/pom.xml | 103 ++++++++++ openapi/openapi-test/pom.xml | 40 ++++ openapi/pom.xml | 91 +++++++++ pom.xml | 31 ++- 8 files changed, 685 insertions(+), 4 deletions(-) create mode 100644 openapi/README.md create mode 100644 openapi/openapi-client/pom.xml create mode 100644 openapi/openapi-model/pom.xml create mode 100644 openapi/openapi-model/src/main/resources/3d-api.yaml create mode 100644 openapi/openapi-server/pom.xml create mode 100644 openapi/openapi-test/pom.xml create mode 100644 openapi/pom.xml diff --git a/openapi/README.md b/openapi/README.md new file mode 100644 index 00000000..0ceaddab --- /dev/null +++ b/openapi/README.md @@ -0,0 +1,2 @@ +# openapi-parent +Various dependency management for the open-api artifacts. \ No newline at end of file diff --git a/openapi/openapi-client/pom.xml b/openapi/openapi-client/pom.xml new file mode 100644 index 00000000..dabe71f8 --- /dev/null +++ b/openapi/openapi-client/pom.xml @@ -0,0 +1,121 @@ + + 4.0.0 + + com.github.skjolber.3d-bin-container-packing + openapi-parent + 4.0.0-SNAPSHOT + ../pom.xml + + openapi-client + + + io.swagger + swagger-annotations + + + org.apache.httpcomponents.client5 + httpclient5 + + + org.apache.commons + commons-lang3 + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + org.openapitools + jackson-databind-nullable + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + com.github.skjolber.3d-bin-container-packing + openapi-model + + + org.mockito + mockito-core + test + + + com.google.truth.extensions + truth-java8-extension + test + + + com.google.truth + truth + test + + + com.github.skjolber.3d-bin-container-packing + openapi-test + test + + + com.github.skjolber.3d-bin-container-packing + openapi-server + test + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.openapitools + openapi-generator-maven-plugin + + + + generate + + + ${maven.multiModuleProjectDirectory}/openapi/openapi-model/src/main/resources/3d-api.yaml + java + + src/gen/java/main + true + jackson + false + + + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + + + + apache-httpclient + supportUrlQuery=false + + true + false + true + + com.github.skjolber.packing.openapi.client.api + com.github.skjolber.packing.openapi.model + com.github.skjolber.packing.openapi.invoker + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/openapi/openapi-model/pom.xml b/openapi/openapi-model/pom.xml new file mode 100644 index 00000000..e91245f2 --- /dev/null +++ b/openapi/openapi-model/pom.xml @@ -0,0 +1,118 @@ + + 4.0.0 + + com.github.skjolber.3d-bin-container-packing + openapi-parent + 4.0.0-SNAPSHOT + ../pom.xml + + openapi-model + + + io.swagger + swagger-annotations + + + org.apache.httpcomponents.client5 + httpclient5 + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + org.apache.commons + commons-lang3 + + + org.openapitools + jackson-databind-nullable + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + jakarta.annotation + jakarta.annotation-api + + + jakarta.validation + jakarta.validation-api + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.openapitools + openapi-generator-maven-plugin + + + + generate + + + ${project.basedir}/src/main/resources/3d-api.yaml + java + + src/gen/java/main + true + jackson + false + + + @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) + + + + apache-httpclient + supportUrlQuery=false + + false + true + false + + com.github.skjolber.packing.openapi.model + com.github.skjolber.packing.openapi.invoker + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/openapi/openapi-model/src/main/resources/3d-api.yaml b/openapi/openapi-model/src/main/resources/3d-api.yaml new file mode 100644 index 00000000..2033858b --- /dev/null +++ b/openapi/openapi-model/src/main/resources/3d-api.yaml @@ -0,0 +1,183 @@ +--- +openapi: 3.0.0 +info: + title: Pack API reference + description: | + Pack boxes into containers + version: 1.0.0 +paths: + /pack: + post: + summary: Pack an order + description: | + Pack an order + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/PackRequest" + responses: + "200": + description: Pack response + content: + application/json: + schema: + $ref: "#/components/schemas/PackResponse" + +components: + schemas: + StackValue: + type: object + discriminator: + propertyName: stackableValueType + mapping: + box: "#/components/schemas/BoxStackValue" + container: "#/components/schemas/ContainerStackValue" + properties: + dx: + type: integer + dy: + type: integer + dz: + type: integer + Stackable: + type: object + discriminator: + propertyName: stackableType + mapping: + box: "#/components/schemas/Box" + container: "#/components/schemas/Container" + properties: + id: + type: string + description: + type: string + ContainerStackValue: + allOf: + - $ref: "#/components/schemas/StackValue" + - type: object + properties: + minLoadWeight: + type: integer + maxLoadWeight: + type: integer + loadDx: + type: integer + loadDy: + type: integer + loadDz: + type: integer + Container: + allOf: + - $ref: "#/components/schemas/Stackable" + - type: object + properties: + emptyWeight: + type: integer + stackValues: + type: array + items: + $ref: '#/components/schemas/ContainerStackValue' + cost: + type: integer + + ContainerItem: + allOf: + - $ref: "#/components/schemas/StackableItem" + - type: object + properties: + container: + $ref: '#/components/schemas/Container' + + BoxStackValue: + allOf: # Combines the BasicErrorModel and the inline model + - $ref: "#/components/schemas/StackValue" + + Box: + allOf: + - $ref: "#/components/schemas/Stackable" + - type: object + properties: + weight: + type: integer + stackValues: + type: array + items: + $ref: '#/components/schemas/BoxStackValue' + + StackableItem: + type: object + discriminator: + propertyName: stackableType + mapping: + box: "#/components/schemas/BoxItem" + container: "#/components/schemas/ContainerItem" + properties: + count: + type: integer + + BoxItem: + allOf: + - $ref: "#/components/schemas/StackableItem" + - type: object + properties: + box: + $ref: '#/components/schemas/Box' + + Stack: + type: object + properties: + placements: + type: array + items: + $ref: '#/components/schemas/StackPlacement' + + StackPlacement: + type: object + properties: + stackable: + $ref: '#/components/schemas/Box' + stackValue: + $ref: '#/components/schemas/BoxStackValue' + x: + type: integer + y: + type: integer + z: + type: integer + Packager: + type: object + properties: + id: + type: string + PackResponse: + type: object + properties: + status: + type: integer + stacks: + type: array + items: + $ref: '#/components/schemas/Stack' + PackRequest: + type: object + properties: + deadline: + type: integer + maxContainers: + type: integer + maxDuration: + type: integer + containerItems: + type: array + items: + $ref: '#/components/schemas/ContainerItem' + boxItems: + type: array + items: + $ref: '#/components/schemas/BoxItem' + packagers: + type: array + items: + $ref: '#/components/schemas/Packager' diff --git a/openapi/openapi-server/pom.xml b/openapi/openapi-server/pom.xml new file mode 100644 index 00000000..7712dcd5 --- /dev/null +++ b/openapi/openapi-server/pom.xml @@ -0,0 +1,103 @@ + + 4.0.0 + + com.github.skjolber.3d-bin-container-packing + openapi-parent + 4.0.0-SNAPSHOT + ../pom.xml + + openapi-server + + + io.swagger + swagger-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + jakarta.annotation + jakarta.annotation-api + + + jakarta.validation + jakarta.validation-api + + + org.openapitools + jackson-databind-nullable + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + org.springframework + spring-web + + + org.springframework + spring-context + + + com.github.skjolber.3d-bin-container-packing + openapi-model + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.openapitools + openapi-generator-maven-plugin + + + + generate + + + ${project.basedir}/../openapi-model/src/main/resources/3d-api.yaml + spring + + src/gen/java/main + true + true + none + true + true + + + spring-boot + false + true + + true + false + false + + com.github.skjolber.packing.openapi.server.api + com.github.skjolber.packing.openapi.model + com.github.skjolber.packing.openapi.invoker + + + + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/openapi/openapi-test/pom.xml b/openapi/openapi-test/pom.xml new file mode 100644 index 00000000..4f387ecb --- /dev/null +++ b/openapi/openapi-test/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + + com.github.skjolber.3d-bin-container-packing + openapi-parent + 4.0.0-SNAPSHOT + ../pom.xml + + openapi-test + + + org.mockito + mockito-core + + + com.github.skjolber.3d-bin-container-packing + openapi-model + + + com.github.skjolber.3d-bin-container-packing + openapi-server + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + diff --git a/openapi/pom.xml b/openapi/pom.xml new file mode 100644 index 00000000..d289f441 --- /dev/null +++ b/openapi/pom.xml @@ -0,0 +1,91 @@ + + 4.0.0 + + + com.github.skjolber.3d-bin-container-packing + parent + 4.0.0-SNAPSHOT + ../pom.xml + + + openapi-parent + pom + + 1.6.12 + 5.4.1 + 6.2.0 + 2.12.0 + 5.4.1 + 7.10.0 + + + + + + org.openapitools + jackson-databind-nullable + 0.2.6 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + org.apache.commons + commons-pool2 + ${commons-pool2.version} + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + org.apache.httpcomponents.client5 + httpclient5 + ${http-client5.version} + + + jakarta.annotation + jakarta.annotation-api + 3.0.0 + + + jakarta.validation + jakarta.validation-api + 3.1.0 + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + + + + + + + + org.openapitools + openapi-generator-maven-plugin + ${openapi-generator-version} + + + + + + + openapi-model + openapi-server + openapi-client + openapi-test + + diff --git a/pom.xml b/pom.xml index 89b945aa..d4ec8bdf 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ 3.26.3 5.3.2 1.16.1 - 2.17.2 + 2.18.2 2.43.0 @@ -95,6 +95,26 @@ test ${project.version} + + com.github.skjolber.3d-bin-container-packing + openapi-model + ${project.version} + + + com.github.skjolber.3d-bin-container-packing + openapi-client + ${project.version} + + + com.github.skjolber.3d-bin-container-packing + openapi-server + ${project.version} + + + com.github.skjolber.3d-bin-container-packing + openapi-test + ${project.version} + com.github.skjolber.3d-bin-container-packing visualizer-packaging @@ -198,10 +218,12 @@ ${commons-io.version} - com.fasterxml.jackson.core - jackson-databind + com.fasterxml.jackson + jackson-bom ${jackson.version} - + import + pom + @@ -210,6 +232,7 @@ extreme-points core jmh + openapi visualizer/api visualizer/algorithm visualizer/packaging