From 0061dfe1b1346455ecb9cdbd06caa1d06ab15ed4 Mon Sep 17 00:00:00 2001 From: Daniel Kmiecik Date: Fri, 20 Nov 2026 15:28:52 +0100 Subject: [PATCH 1/3] feat: add spring-boot4 petstore sample, tests and CI workflow --- .../test-framework-v3-springboot4.yml | 175 +++++++++ bin/springboot4-petstore-server.sh | 39 ++ pom.docker.xml | 13 +- pom.xml | 13 +- .../spring/v3/springboot4/PetApiTest.java | 80 +++++ .../spring/v3/springboot4/StoreApiTest.java | 47 +++ .../spring/v3/springboot4/UserApiTest.java | 70 ++++ samples/meta-codegen/pom.xml | 2 +- .../springboot-4/.swagger-codegen-ignore | 23 ++ .../springboot-4/.swagger-codegen/VERSION | 1 + .../server/petstore/springboot-4/README.md | 22 ++ samples/server/petstore/springboot-4/pom.xml | 84 +++++ .../java/io/swagger/OpenAPISpringBoot.java | 56 +++ .../java/io/swagger/api/ApiException.java | 10 + .../java/io/swagger/api/ApiOriginFilter.java | 27 ++ .../io/swagger/api/ApiResponseMessage.java | 69 ++++ .../main/java/io/swagger/api/DefaultApi.java | 83 +++++ .../io/swagger/api/DefaultApiController.java | 32 ++ .../io/swagger/api/NotFoundException.java | 10 + .../src/main/java/io/swagger/api/PetApi.java | 336 ++++++++++++++++++ .../java/io/swagger/api/PetApiController.java | 32 ++ .../main/java/io/swagger/api/StoreApi.java | 159 +++++++++ .../io/swagger/api/StoreApiController.java | 32 ++ .../src/main/java/io/swagger/api/UserApi.java | 213 +++++++++++ .../io/swagger/api/UserApiController.java | 32 ++ .../swagger/configuration/HomeController.java | 16 + .../configuration/LocalDateConverter.java | 21 ++ .../configuration/LocalDateTimeConverter.java | 21 ++ .../swagger/configuration/NotUndefined.java | 15 + .../configuration/NotUndefinedValidator.java | 36 ++ .../configuration/SwaggerUiConfiguration.java | 16 + .../model/AllOfSubCategoryCategory.java | 189 ++++++++++ .../model/AllOfSubCategoryPetsItems.java | 62 ++++ .../io/swagger/model/AllPetsResponse.java | 60 ++++ .../src/main/java/io/swagger/model/Cat.java | 129 +++++++ .../main/java/io/swagger/model/Category.java | 123 +++++++ .../src/main/java/io/swagger/model/Dog.java | 163 +++++++++ .../io/swagger/model/ModelApiResponse.java | 154 ++++++++ .../io/swagger/model/NullableEnumModel.java | 124 +++++++ .../model/OneOfAllPetsResponseItems.java | 19 + .../model/OneOfSinglePetResponsePet.java | 19 + .../src/main/java/io/swagger/model/Order.java | 282 +++++++++++++++ .../src/main/java/io/swagger/model/Pet.java | 294 +++++++++++++++ .../java/io/swagger/model/PetPetIdBody.java | 123 +++++++ .../io/swagger/model/SinglePetResponse.java | 92 +++++ .../java/io/swagger/model/SubCategory.java | 163 +++++++++ .../src/main/java/io/swagger/model/Tag.java | 123 +++++++ .../src/main/java/io/swagger/model/User.java | 309 ++++++++++++++++ .../src/main/resources/application.properties | 3 + 49 files changed, 4205 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/test-framework-v3-springboot4.yml create mode 100755 bin/springboot4-petstore-server.sh create mode 100644 samples/custom-tests/spring/v3/springboot4/PetApiTest.java create mode 100644 samples/custom-tests/spring/v3/springboot4/StoreApiTest.java create mode 100644 samples/custom-tests/spring/v3/springboot4/UserApiTest.java create mode 100644 samples/server/petstore/springboot-4/.swagger-codegen-ignore create mode 100644 samples/server/petstore/springboot-4/.swagger-codegen/VERSION create mode 100644 samples/server/petstore/springboot-4/README.md create mode 100644 samples/server/petstore/springboot-4/pom.xml create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/OpenAPISpringBoot.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiException.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiOriginFilter.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiResponseMessage.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApiController.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/NotFoundException.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApiController.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApiController.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApiController.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/HomeController.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateConverter.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateTimeConverter.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefined.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefinedValidator.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryCategory.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryPetsItems.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllPetsResponse.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Cat.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Category.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Dog.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/ModelApiResponse.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/NullableEnumModel.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfAllPetsResponseItems.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfSinglePetResponsePet.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Order.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Pet.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/PetPetIdBody.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SinglePetResponse.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SubCategory.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Tag.java create mode 100644 samples/server/petstore/springboot-4/src/main/java/io/swagger/model/User.java create mode 100644 samples/server/petstore/springboot-4/src/main/resources/application.properties diff --git a/.github/workflows/test-framework-v3-springboot4.yml b/.github/workflows/test-framework-v3-springboot4.yml new file mode 100644 index 00000000000..0b697c7a7e9 --- /dev/null +++ b/.github/workflows/test-framework-v3-springboot4.yml @@ -0,0 +1,175 @@ +name: Test Framework V3 Springboot4 (Spring Boot 4 / Jackson 3) + +on: + # execute on demand + workflow_dispatch: + branches: ["3.0.0"] + +jobs: + + # builds codegen cli and uploads its artifact + build-codegen: + + runs-on: ubuntu-latest + + strategy: + matrix: + java: [ 11 ] + + steps: + - uses: actions/checkout@v2 + with: + ref: 3.0.0 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: build codegen + run: | + mkdir codegen-cli + echo "BUILDING 3.0.0" + mvn -version + mvn -q -B package -DskipTests -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3 + cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli + - name: upload codegen cli + uses: actions/upload-artifact@v2 + with: + name: codegen-cli + path: codegen-cli + - name: upload test files + uses: actions/upload-artifact@v2 + with: + name: spring-custom-test-files + path: samples/custom-tests/spring/v3/springboot4 + + generate: + + needs: build-codegen + + runs-on: ubuntu-latest + + strategy: + matrix: + java: [ 21 ] + + + outputs: + generate_outcome: ${{ steps.outcome.outputs.generate_outcome }} + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Download codegen cli + uses: actions/download-artifact@v2 + with: + name: codegen-cli + - name: generate + id: generate + continue-on-error: true + uses: ./.github/actions/generate + with: + language: spring + job-name: ${{ env.JOB_NAME }} + spec-url: https://raw.githubusercontent.com/swagger-api/swagger-codegen/3.0.0/modules/swagger-codegen/src/test/resources/3_0_0/petstore-with-issue-cases.yaml + options: "--library spring-boot4" + - id: outcome + run: | + echo "generate_outcome=${{ steps.generate.outcome }}" >> $GITHUB_OUTPUT + echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }} + - name: upload generate outcome + uses: actions/upload-artifact@v2 + with: + name: ${{ env.JOB_NAME }}generate_outcome + path: generate_outcome_${{ env.JOB_NAME }} + - name: upload generate logs + uses: actions/upload-artifact@v2 + with: + name: ${{ env.JOB_NAME }}generate_logs + path: ${{ steps.generate.outputs.logs }} + - name: upload generated code + if: contains(steps.generate.outcome, 'success') + uses: actions/upload-artifact@v2 + with: + name: ${{ env.JOB_NAME }}generated + path: ${{ steps.generate.outputs.path }} + env: + JOB_NAME: "springboot4-v3-sample" + + build: + + needs: generate + if: contains(needs.generate.outputs.generate_outcome, 'success') + runs-on: ubuntu-latest + + strategy: + ############################################### + ##### DYNAMIC: Dependent on build environment + ############################################### + matrix: + java-version: [17, 21] + ############################################### + ##### END DYNAMIC: Dependent on build environment + ############################################### + steps: + - uses: actions/checkout@v2 + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: ${{ env.JOB_NAME }}generated + path: generated/${{ env.JOB_NAME }} + - name: Download logs + uses: actions/download-artifact@v2 + with: + name: ${{ env.JOB_NAME }}generate_logs + ############################################### + ##### DYNAMIC: Dependent on build environment + ############################################### + - name: Set up JDK ${{ matrix.java-version }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java-version }} + ############################################### + ##### END DYNAMIC: Dependent on build environment + ############################################### + - name: Download Java Test Files + uses: actions/download-artifact@v2 + with: + name: spring-custom-test-files + path: spring-custom-test-files + - name: setup test files + id: test-files + run: | + echo "adding test directories path" + + mkdir -p generated/${{ env.JOB_NAME }}/src/test/java/io/swagger/api + + echo "copying custom test files" + cp spring-custom-test-files/PetApiTest.java generated/${{ env.JOB_NAME }}/src/test/java/io/swagger/api/ + cp spring-custom-test-files/StoreApiTest.java generated/${{ env.JOB_NAME }}/src/test/java/io/swagger/api/ + cp spring-custom-test-files/UserApiTest.java generated/${{ env.JOB_NAME }}/src/test/java/io/swagger/api/ + + - name: build + id: build + uses: ./.github/actions/build + continue-on-error: true + with: + path: generated/${{ env.JOB_NAME }} + job-name: ${{ env.JOB_NAME }} + build-commands: "mvn clean package -Dmaven.compiler.release=${{ matrix.java-version }} -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3" + - id: outcome + run: | + echo "build_outcome=${{ steps.build.outcome }}" >> $GITHUB_OUTPUT + echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome + - name: upload build outcome + uses: actions/upload-artifact@v2 + with: + name: ${{ env.JOB_NAME }}build_outcome-java${{ matrix.java-version }} + path: ${{ env.JOB_NAME }}build_outcome + - name: upload logs + uses: actions/upload-artifact@v2 + with: + name: ${{ env.JOB_NAME }}logs-java${{ matrix.java-version }} + path: ${{ steps.build.outputs.logs }} + env: + JOB_NAME: "springboot4-v3-sample" diff --git a/bin/springboot4-petstore-server.sh b/bin/springboot4-petstore-server.sh new file mode 100755 index 00000000000..263f9c8b447 --- /dev/null +++ b/bin/springboot4-petstore-server.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +output="samples/server/petstore/springboot-4" +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -Dlogback.configurationFile=bin/logback.xml" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/3_0_0/petstore.yaml -l spring --library spring-boot4 -o $output -DhideGenerationTimestamp=true" + +echo "Removing files and folders under samples/server/petstore/springboot-4/src/main" +rm -rf samples/server/petstore/springboot-4/src/main +rm -rf samples/server/petstore/springboot-4/src/gen +find samples/server/petstore/springboot-4 -maxdepth 1 -type f ! -name "README.md" -exec rm {} + +java $JAVA_OPTS -jar $executable $ags + +#cd $output +#mvn package diff --git a/pom.docker.xml b/pom.docker.xml index 411393d240a..c1cc92355d6 100644 --- a/pom.docker.xml +++ b/pom.docker.xml @@ -137,7 +137,6 @@ 1.8 UTF-8 1g - ${javadoc.package.exclude} -Xdoclint:none @@ -832,9 +831,13 @@ org.apache.maven.plugins maven-jxr-plugin 3.6.0 - - true - + + + + aggregate + + + org.apache.maven.plugins @@ -1004,7 +1007,7 @@ 8 - 1.0.63 + 1.0.64-SNAPSHOT 2.2.55 1.6.16 2.1.48 diff --git a/pom.xml b/pom.xml index 16a24243bee..7166e1a7e28 100644 --- a/pom.xml +++ b/pom.xml @@ -139,7 +139,6 @@ 1.8 UTF-8 1g - ${javadoc.package.exclude} -Xdoclint:none @@ -898,9 +897,13 @@ org.apache.maven.plugins maven-jxr-plugin 3.6.0 - - true - + + + + aggregate + + + org.apache.maven.plugins @@ -1070,7 +1073,7 @@ 8 - 1.0.63 + 1.0.64-SNAPSHOT 2.2.56 1.6.17 2.1.49 diff --git a/samples/custom-tests/spring/v3/springboot4/PetApiTest.java b/samples/custom-tests/spring/v3/springboot4/PetApiTest.java new file mode 100644 index 00000000000..2a15b7b8e5f --- /dev/null +++ b/samples/custom-tests/spring/v3/springboot4/PetApiTest.java @@ -0,0 +1,80 @@ +package io.swagger.api; + +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest +public class PetApiTest { + + @Autowired + private PetApi api; + + @Test + public void addPetTest() throws Exception { + Pet body = new Pet() + .id(789L) + .name("doggie") + .status(Pet.StatusEnum.AVAILABLE); + ResponseEntity responseEntity = api.addPet(body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void deletePetTest() throws Exception { + Long petId = 789L; + String apiKey = "apiKey_example"; + ResponseEntity responseEntity = api.deletePet(petId, apiKey); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void findPetsByStatusTest() throws Exception { + String status = "available"; + ResponseEntity> responseEntity = api.findPetsByStatus(status); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void findPetsByTagsTest() throws Exception { + List tags = Arrays.asList("tags_example"); + ResponseEntity> responseEntity = api.findPetsByTags(tags); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void getPetByIdTest() throws Exception { + Long petId = 789L; + ResponseEntity responseEntity = api.getPetById(petId); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void updatePetTest() throws Exception { + Pet body = new Pet() + .id(789L) + .name("doggie") + .status(Pet.StatusEnum.AVAILABLE); + ResponseEntity responseEntity = api.updatePet(body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void uploadFileTest() throws Exception { + Long petId = 789L; + String additionalMetadata = "additionalMetadata_example"; + org.springframework.web.multipart.MultipartFile body = null; + ResponseEntity responseEntity = api.uploadFile(petId, additionalMetadata, body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + +} diff --git a/samples/custom-tests/spring/v3/springboot4/StoreApiTest.java b/samples/custom-tests/spring/v3/springboot4/StoreApiTest.java new file mode 100644 index 00000000000..1df599e4c82 --- /dev/null +++ b/samples/custom-tests/spring/v3/springboot4/StoreApiTest.java @@ -0,0 +1,47 @@ +package io.swagger.api; + +import io.swagger.model.Order; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest +public class StoreApiTest { + + @Autowired + private StoreApi api; + + @Test + public void deleteOrderTest() throws Exception { + Long orderId = 789L; + ResponseEntity responseEntity = api.deleteOrder(orderId); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void getInventoryTest() throws Exception { + ResponseEntity> responseEntity = api.getInventory(); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void getOrderByIdTest() throws Exception { + Long orderId = 789L; + ResponseEntity responseEntity = api.getOrderById(orderId); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void placeOrderTest() throws Exception { + Order body = new Order(); + ResponseEntity responseEntity = api.placeOrder(body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + +} diff --git a/samples/custom-tests/spring/v3/springboot4/UserApiTest.java b/samples/custom-tests/spring/v3/springboot4/UserApiTest.java new file mode 100644 index 00000000000..d395ea32ce7 --- /dev/null +++ b/samples/custom-tests/spring/v3/springboot4/UserApiTest.java @@ -0,0 +1,70 @@ +package io.swagger.api; + +import io.swagger.model.User; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; + +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@SpringBootTest +public class UserApiTest { + + @Autowired + private UserApi api; + + @Test + public void createUserTest() throws Exception { + User body = new User(); + ResponseEntity responseEntity = api.createUser(body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void createUsersWithListInputTest() throws Exception { + List body = Arrays.asList(new User()); + ResponseEntity responseEntity = api.createUsersWithListInput(body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void deleteUserTest() throws Exception { + String username = "username_example"; + ResponseEntity responseEntity = api.deleteUser(username); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void getUserByNameTest() throws Exception { + String username = "username_example"; + ResponseEntity responseEntity = api.getUserByName(username); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void loginUserTest() throws Exception { + String username = "username_example"; + String password = "password_example"; + ResponseEntity responseEntity = api.loginUser(username, password); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void logoutUserTest() throws Exception { + ResponseEntity responseEntity = api.logoutUser(); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } + + @Test + public void updateUserTest() throws Exception { + String username = "username_example"; + User body = new User(); + ResponseEntity responseEntity = api.updateUser(username, body); + assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode()); + } +} diff --git a/samples/meta-codegen/pom.xml b/samples/meta-codegen/pom.xml index ad7e02c2a03..1bf31872d46 100644 --- a/samples/meta-codegen/pom.xml +++ b/samples/meta-codegen/pom.xml @@ -121,7 +121,7 @@ UTF-8 3.0.86 - 1.0.63 + 1.0.64-SNAPSHOT 1.0.0 4.13.2 3.0.0 diff --git a/samples/server/petstore/springboot-4/.swagger-codegen-ignore b/samples/server/petstore/springboot-4/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/server/petstore/springboot-4/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/server/petstore/springboot-4/.swagger-codegen/VERSION b/samples/server/petstore/springboot-4/.swagger-codegen/VERSION new file mode 100644 index 00000000000..cc5c6b79360 --- /dev/null +++ b/samples/server/petstore/springboot-4/.swagger-codegen/VERSION @@ -0,0 +1 @@ +3.0.86-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/springboot-4/README.md b/samples/server/petstore/springboot-4/README.md new file mode 100644 index 00000000000..47a54b75f9b --- /dev/null +++ b/samples/server/petstore/springboot-4/README.md @@ -0,0 +1,22 @@ +# Swagger generated server + +Spring Boot 4 Server (Spring Framework 7, Jackson 3) + + +## Overview +This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. +By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. +This is an example of building a swagger-enabled server in Java using the SpringBoot framework. + +Requirements: Java 21+ (Spring Boot 4 needs Java 17 or newer). +The generated API interfaces carry default methods (the `java8` option is always on for this library). +JSON (de)serialization uses Jackson 3 (`tools.jackson.*`); Jackson annotations stay on `com.fasterxml.jackson.annotation`. + +The underlying library integrating swagger to SpringBoot is [springdoc-openapi](https://github.com/springdoc/springdoc-openapi) + +Start your server as an simple java application + +You can view the api documentation in swagger-ui by pointing to +http://localhost:8080/ + +Change default port value in application.properties \ No newline at end of file diff --git a/samples/server/petstore/springboot-4/pom.xml b/samples/server/petstore/springboot-4/pom.xml new file mode 100644 index 00000000000..215d7ff853c --- /dev/null +++ b/samples/server/petstore/springboot-4/pom.xml @@ -0,0 +1,84 @@ + + 4.0.0 + io.swagger + swagger-spring + jar + swagger-spring + 1.0.0 + + UTF-8 + 21 + 4.1.3 + 2.2.25 + 3.2.0 + 0.2.13 + + + org.springframework.boot + spring-boot-starter-parent + 4.1.3 + + + src/main/java + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + + org.springframework.boot + spring-boot-starter-webmvc + + + org.springframework.boot + spring-boot-starter-validation + + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + jakarta.validation + jakarta.validation-api + + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.glassfish.jaxb + jaxb-runtime + + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-version} + + + + io.swagger.core.v3 + swagger-annotations + ${swagger-annotations-version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/OpenAPISpringBoot.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/OpenAPISpringBoot.java new file mode 100644 index 00000000000..0c86d66aa0e --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/OpenAPISpringBoot.java @@ -0,0 +1,56 @@ +package io.swagger; + +import io.swagger.configuration.LocalDateConverter; +import io.swagger.configuration.LocalDateTimeConverter; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.ExitCodeGenerator; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.openapitools.jackson.nullable.JsonNullableJackson3Module; +import org.springframework.context.annotation.Bean; +import tools.jackson.databind.JacksonModule; + + +@SpringBootApplication +@ComponentScan(basePackages = { "io.swagger", "io.swagger.api" , "io.swagger.configuration"}) +public class OpenAPISpringBoot implements CommandLineRunner { + + @Override + public void run(String... arg0) throws Exception { + if (arg0.length > 0 && arg0[0].equals("exitcode")) { + throw new ExitException(); + } + } + + public static void main(String[] args) throws Exception { + new SpringApplication(OpenAPISpringBoot.class).run(args); + } + @Bean + public JacksonModule jsonNullableModule() { + return new JsonNullableJackson3Module(); + } + + @Configuration + static class CustomDateConfig implements WebMvcConfigurer { + @Override + public void addFormatters(FormatterRegistry registry) { + registry.addConverter(new LocalDateConverter("yyyy-MM-dd")); + registry.addConverter(new LocalDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss.SSS")); + } + } + + class ExitException extends RuntimeException implements ExitCodeGenerator { + private static final long serialVersionUID = 1L; + + @Override + public int getExitCode() { + return 10; + } + + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiException.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiException.java new file mode 100644 index 00000000000..410d2de5230 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class ApiException extends Exception { + private int code; + public ApiException (int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiOriginFilter.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiOriginFilter.java new file mode 100644 index 00000000000..6983edbe9dd --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiOriginFilter.java @@ -0,0 +1,27 @@ +package io.swagger.api; + +import java.io.IOException; + +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletResponse; + + +public class ApiOriginFilter implements Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + @Override + public void destroy() { + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiResponseMessage.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiResponseMessage.java new file mode 100644 index 00000000000..bfe2f1d8b52 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/ApiResponseMessage.java @@ -0,0 +1,69 @@ +package io.swagger.api; + +import jakarta.xml.bind.annotation.XmlTransient; + + +@jakarta.xml.bind.annotation.XmlRootElement +public class ApiResponseMessage { + public static final int ERROR = 1; + public static final int WARNING = 2; + public static final int INFO = 3; + public static final int OK = 4; + public static final int TOO_BUSY = 5; + + int code; + String type; + String message; + + public ApiResponseMessage(){} + + public ApiResponseMessage(int code, String message){ + this.code = code; + switch(code){ + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + @XmlTransient + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java new file mode 100644 index 00000000000..97bdccb41d4 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java @@ -0,0 +1,83 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import tools.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.CookieValue; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.core.JacksonException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + +@Validated +public interface DefaultApi { + + Logger log = LoggerFactory.getLogger(DefaultApi.class); + + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest(){ + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + @Operation(summary = "", description = "", security = { + @SecurityRequirement(name = "bearer") }, tags={ }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "peticion realizada con exito", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = String.class)))) }) + @RequestMapping(value = "/test", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> testMethod() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ \"\", \"\" ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default DefaultApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} + diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApiController.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApiController.java new file mode 100644 index 00000000000..bd66672bd60 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApiController.java @@ -0,0 +1,32 @@ +package io.swagger.api; + +import tools.jackson.databind.ObjectMapper; +import org.springframework.web.bind.annotation.RestController; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Optional; + + +@RestController +public class DefaultApiController implements DefaultApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public DefaultApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/NotFoundException.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/NotFoundException.java new file mode 100644 index 00000000000..b28b67ea4b2 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/NotFoundException.java @@ -0,0 +1,10 @@ +package io.swagger.api; + + +public class NotFoundException extends ApiException { + private int code; + public NotFoundException (int code, String msg) { + super(code, msg); + this.code = code; + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..606adfd5661 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java @@ -0,0 +1,336 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import io.swagger.model.AllPetsResponse; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; +import io.swagger.model.SinglePetResponse; +import io.swagger.model.SubCategory; +import tools.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.CookieValue; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.core.JacksonException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + +@Validated +public interface PetApi { + + Logger log = LoggerFactory.getLogger(PetApi.class); + + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest(){ + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "405", description = "Invalid input") }) + @RequestMapping(value = "/pet", + consumes = { "application/json", "application/xml" }, + method = RequestMethod.POST) + default ResponseEntity addPet(@Parameter(in = ParameterIn.DEFAULT, description = "Pet object that needs to be added to the store", required=true, schema=@Schema()) @Valid @RequestBody Pet body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @RequestMapping(value = "/pet/{petId}", + method = RequestMethod.DELETE) + default ResponseEntity deletePet(@Parameter(in = ParameterIn.PATH, description = "Pet id to delete", required=true, schema=@Schema()) @PathVariable("petId") Long petId +, @Parameter(in = ParameterIn.HEADER, description = "" ,schema=@Schema()) @RequestHeader(value="api_key", required=false) String apiKey +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "", description = "", tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) }) + @RequestMapping(value = "/pet/category", + produces = { "application/json" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity doCategoryStuff(@Parameter(in = ParameterIn.DEFAULT, description = "", schema=@Schema()) @Valid @RequestBody SubCategory body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @RequestMapping(value = "/pet/findByStatus", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity> findPetsByStatus(@NotNull @Parameter(in = ParameterIn.QUERY, description = "Status values that need to be considered for filter" ,required=true,schema=@Schema(allowableValues={ "available", "pending", "sold" } +)) @Valid @RequestParam(value = "status", required = true) List status +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use\\ \\ tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @RequestMapping(value = "/pet/findByTags", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity> findPetsByTags(@NotNull @Parameter(in = ParameterIn.QUERY, description = "Tags to filter by" ,required=true,schema=@Schema()) @Valid @RequestParam(value = "tags", required = true) List tags +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]", List.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "", description = "", tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "a single random pet", content = @Content(mediaType = "application/json", schema = @Schema(implementation = AllPetsResponse.class))) }) + @RequestMapping(value = "/allPets", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity getAllPets() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("[ \"\", \"\" ]", AllPetsResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))), + + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @RequestMapping(value = "/pet/{petId}", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity getPetById(@Parameter(in = ParameterIn.PATH, description = "ID of pet to return", required=true, schema=@Schema()) @PathVariable("petId") Long petId +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}", Pet.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "", description = "", tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "a single random pet", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SinglePetResponse.class))) }) + @RequestMapping(value = "/randomPet", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity getRandomPet() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"pet\" : \"\"\n}", SinglePetResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + + @ApiResponse(responseCode = "404", description = "Pet not found"), + + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @RequestMapping(value = "/pet", + consumes = { "application/json", "application/xml" }, + method = RequestMethod.PUT) + default ResponseEntity updatePet(@Parameter(in = ParameterIn.DEFAULT, description = "Pet object that needs to be added to the store", required=true, schema=@Schema()) @Valid @RequestBody Pet body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "405", description = "Invalid input") }) + @RequestMapping(value = "/pet/{petId}", + consumes = { "application/x-www-form-urlencoded" }, + method = RequestMethod.POST) + default ResponseEntity updatePetWithForm(@Parameter(in = ParameterIn.PATH, description = "ID of pet that needs to be updated", required=true, schema=@Schema()) @PathVariable("petId") Long petId +, @Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="name", required=false) String name +, @Parameter(in = ParameterIn.DEFAULT, description = "",schema=@Schema()) @RequestParam(value="status", required=false) String status +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { + "write:pets", +"read:pets" }) }, tags={ "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))) }) + @RequestMapping(value = "/pet/{petId}/uploadImage", + produces = { "application/json" }, + consumes = { "application/octet-stream" }, + method = RequestMethod.POST) + default ResponseEntity uploadFile(@Parameter(in = ParameterIn.PATH, description = "ID of pet to update", required=true, schema=@Schema()) @PathVariable("petId") Long petId +, @Parameter(in = ParameterIn.DEFAULT, description = "", schema=@Schema()) @Valid @RequestBody Object body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}", ModelApiResponse.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default PetApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} + diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApiController.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApiController.java new file mode 100644 index 00000000000..c68e8f64d5e --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApiController.java @@ -0,0 +1,32 @@ +package io.swagger.api; + +import tools.jackson.databind.ObjectMapper; +import org.springframework.web.bind.annotation.RestController; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Optional; + + +@RestController +public class PetApiController implements PetApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public PetApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..2fb02223176 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java @@ -0,0 +1,159 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; +import tools.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.CookieValue; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.core.JacksonException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + +@Validated +public interface StoreApi { + + Logger log = LoggerFactory.getLogger(StoreApi.class); + + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest(){ + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + @Operation(summary = "Delete purchase order by ID", description = "For valid response try integer IDs with positive integer value.\\ \\ Negative or non-integer values will generate API errors", tags={ "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + + @ApiResponse(responseCode = "404", description = "Order not found") }) + @RequestMapping(value = "/store/order/{orderId}", + method = RequestMethod.DELETE) + default ResponseEntity deleteOrder(@Min(1L)@Parameter(in = ParameterIn.PATH, description = "ID of the order that needs to be deleted", required=true, schema=@Schema(allowableValues={ "1" }, minimum="1" +)) @PathVariable("orderId") Long orderId +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags={ "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @RequestMapping(value = "/store/inventory", + produces = { "application/json" }, + method = RequestMethod.GET) + default ResponseEntity> getInventory() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"key\" : 0\n}", Map.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Find purchase order by ID", description = "For valid response try integer IDs with value >= 1 and <= 10.\\ \\ Other values will generated exceptions", tags={ "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + + @ApiResponse(responseCode = "404", description = "Order not found") }) + @RequestMapping(value = "/store/order/{orderId}", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity getOrderById(@Min(1L) @Max(10L) @Parameter(in = ParameterIn.PATH, description = "ID of pet that needs to be fetched", required=true, schema=@Schema(allowableValues={ "1", "10" }, minimum="1", maximum="10" +)) @PathVariable("orderId") Long orderId +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Place an order for a pet", description = "", tags={ "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))), + + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @RequestMapping(value = "/store/order", + produces = { "application/json", "application/xml" }, + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity placeOrder(@Parameter(in = ParameterIn.DEFAULT, description = "order placed for purchasing the pet", required=true, schema=@Schema()) @Valid @RequestBody Order body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}", Order.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default StoreApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} + diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApiController.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApiController.java new file mode 100644 index 00000000000..03e552f2079 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApiController.java @@ -0,0 +1,32 @@ +package io.swagger.api; + +import tools.jackson.databind.ObjectMapper; +import org.springframework.web.bind.annotation.RestController; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Optional; + + +@RestController +public class StoreApiController implements StoreApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public StoreApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..11eba9e7533 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java @@ -0,0 +1,213 @@ +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package io.swagger.api; + +import io.swagger.model.User; +import tools.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.bind.annotation.CookieValue; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import tools.jackson.core.JacksonException; +import java.util.List; +import java.util.Map; +import java.util.Optional; + + +@Validated +public interface UserApi { + + Logger log = LoggerFactory.getLogger(UserApi.class); + + default Optional getObjectMapper(){ + return Optional.empty(); + } + + default Optional getRequest(){ + return Optional.empty(); + } + + default Optional getAcceptHeader() { + return getRequest().map(r -> r.getHeader("Accept")); + } + + @Operation(summary = "Create user", description = "This can only be done by the logged in user.", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + @RequestMapping(value = "/user", + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createUser(@Parameter(in = ParameterIn.DEFAULT, description = "Created user object", required=true, schema=@Schema()) @Valid @RequestBody User body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Creates list of users with given input array", description = "", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + @RequestMapping(value = "/user/createWithArray", + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createUsersWithArrayInput(@Parameter(in = ParameterIn.DEFAULT, description = "List of user object", required=true, schema=@Schema()) @Valid @RequestBody List body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Creates list of users with given input array", description = "", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + @RequestMapping(value = "/user/createWithList", + consumes = { "application/json" }, + method = RequestMethod.POST) + default ResponseEntity createUsersWithListInput(@Parameter(in = ParameterIn.DEFAULT, description = "List of user object", required=true, schema=@Schema()) @Valid @RequestBody List body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Delete user", description = "This can only be done by the logged in user.", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + + @ApiResponse(responseCode = "404", description = "User not found") }) + @RequestMapping(value = "/user/{username}", + method = RequestMethod.DELETE) + default ResponseEntity deleteUser(@Parameter(in = ParameterIn.PATH, description = "The name that needs to be deleted", required=true, schema=@Schema()) @PathVariable("username") String username +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Get user by user name", description = "", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = User.class))), + + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + + @ApiResponse(responseCode = "404", description = "User not found") }) + @RequestMapping(value = "/user/{username}", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity getUserByName(@Parameter(in = ParameterIn.PATH, description = "The name that needs to be fetched. Use user1 for testing.", required=true, schema=@Schema()) @PathVariable("username") String username +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}", User.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Logs user into the system", description = "", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @RequestMapping(value = "/user/login", + produces = { "application/json", "application/xml" }, + method = RequestMethod.GET) + default ResponseEntity loginUser(@NotNull @Parameter(in = ParameterIn.QUERY, description = "The user name for login" ,required=true,schema=@Schema()) @Valid @RequestParam(value = "username", required = true) String username +, @NotNull @Parameter(in = ParameterIn.QUERY, description = "The password for login in clear text" ,required=true,schema=@Schema()) @Valid @RequestParam(value = "password", required = true) String password +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + if (getAcceptHeader().get().contains("application/json")) { + try { + return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.class), HttpStatus.NOT_IMPLEMENTED); + } catch (JacksonException e) { + log.error("Couldn't serialize response for content type application/json", e); + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); + } + } + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Logs out current logged in user session", description = "", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation") }) + @RequestMapping(value = "/user/logout", + method = RequestMethod.GET) + default ResponseEntity logoutUser() { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + + + @Operation(summary = "Updated user", description = "This can only be done by the logged in user.", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + + @ApiResponse(responseCode = "404", description = "User not found") }) + @RequestMapping(value = "/user/{username}", + consumes = { "application/json" }, + method = RequestMethod.PUT) + default ResponseEntity userUsernamePut(@Parameter(in = ParameterIn.PATH, description = "name that need to be updated", required=true, schema=@Schema()) @PathVariable("username") String username +, @Parameter(in = ParameterIn.DEFAULT, description = "Updated user object", required=true, schema=@Schema()) @Valid @RequestBody User body +) { + if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) { + } else { + log.warn("ObjectMapper or HttpServletRequest not configured in default UserApi interface so no example is generated"); + } + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + } + +} + diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApiController.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApiController.java new file mode 100644 index 00000000000..e396dc7c8fd --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApiController.java @@ -0,0 +1,32 @@ +package io.swagger.api; + +import tools.jackson.databind.ObjectMapper; +import org.springframework.web.bind.annotation.RestController; +import jakarta.servlet.http.HttpServletRequest; +import java.util.Optional; + + +@RestController +public class UserApiController implements UserApi { + + private final ObjectMapper objectMapper; + + private final HttpServletRequest request; + + @org.springframework.beans.factory.annotation.Autowired + public UserApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + @Override + public Optional getObjectMapper() { + return Optional.ofNullable(objectMapper); + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/HomeController.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/HomeController.java new file mode 100644 index 00000000000..689c5ea1c74 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/HomeController.java @@ -0,0 +1,16 @@ +package io.swagger.configuration; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + @RequestMapping(value = "/") + public String index() { + System.out.println("/swagger-ui/index.html"); + return "redirect:/swagger-ui/"; + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateConverter.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateConverter.java new file mode 100644 index 00000000000..f6a0cb40092 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateConverter.java @@ -0,0 +1,21 @@ +package io.swagger.configuration; + +import org.springframework.core.convert.converter.Converter; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; + +public class LocalDateConverter implements Converter { + private final DateTimeFormatter formatter; + + public LocalDateConverter(String dateFormat) { + this.formatter = DateTimeFormatter.ofPattern(dateFormat); + } + + @Override + public LocalDate convert(String source) { + if(source == null || source.isEmpty()) { + return null; + } + return LocalDate.parse(source, this.formatter); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateTimeConverter.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateTimeConverter.java new file mode 100644 index 00000000000..f189ac7a229 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/LocalDateTimeConverter.java @@ -0,0 +1,21 @@ +package io.swagger.configuration; + +import org.springframework.core.convert.converter.Converter; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class LocalDateTimeConverter implements Converter { + private final DateTimeFormatter formatter; + + public LocalDateTimeConverter(String dateFormat) { + this.formatter = DateTimeFormatter.ofPattern(dateFormat); + } + + @Override + public LocalDateTime convert(String source) { + if(source == null || source.isEmpty()) { + return null; + } + return LocalDateTime.parse(source, this.formatter); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefined.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefined.java new file mode 100644 index 00000000000..50efdbf7d14 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefined.java @@ -0,0 +1,15 @@ +package io.swagger.configuration; + +import jakarta.validation.Constraint; +import jakarta.validation.Payload; +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Constraint(validatedBy = NotUndefinedValidator.class) +public @interface NotUndefined { + String message() default "field cannot be undefined"; + Class[] groups() default {}; + Class[] payload() default {}; +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefinedValidator.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefinedValidator.java new file mode 100644 index 00000000000..d0e416659d9 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/NotUndefinedValidator.java @@ -0,0 +1,36 @@ +package io.swagger.configuration; + +import org.openapitools.jackson.nullable.JsonNullable; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; +import java.lang.reflect.Field; + +public class NotUndefinedValidator implements ConstraintValidator{ + + @Override + public void initialize(NotUndefined constraintAnnotation) { + } + + @Override + public boolean isValid(Object addressInformation, ConstraintValidatorContext context) { + Class objClass = addressInformation.getClass(); + Field[] fields = objClass.getDeclaredFields(); + for (Field field : fields) { + if (field.getType().equals(JsonNullable.class)){ + field.setAccessible(true); + try { + Object value = field.get(addressInformation); + if(value.equals(JsonNullable.undefined())){ + context.disableDefaultConstraintViolation(); + context.buildConstraintViolationWithTemplate(field.getName() + " cannot be undefined") + .addConstraintViolation(); + return false; + } + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + } + return true; + } +} \ No newline at end of file diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java new file mode 100644 index 00000000000..956c1c14c4d --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/configuration/SwaggerUiConfiguration.java @@ -0,0 +1,16 @@ +package io.swagger.configuration; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + + +@Configuration +public class SwaggerUiConfiguration implements WebMvcConfigurer { + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/swagger-ui/").setViewName("forward:/swagger-ui/index.html"); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryCategory.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryCategory.java new file mode 100644 index 00000000000..50351c61f37 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryCategory.java @@ -0,0 +1,189 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.model.Category; +import io.swagger.model.User; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * AllOfSubCategoryCategory + */ +@Validated +@NotUndefined + + + +public class AllOfSubCategoryCategory extends Category { + @JsonProperty("foo") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Boolean foo = null; + + @JsonProperty("bar") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Integer bar = null; + + @JsonProperty("beer") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String beer = null; + + @JsonProperty("drunk") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private User drunk = null; + + + public AllOfSubCategoryCategory foo(Boolean foo) { + + this.foo = foo; + return this; + } + + /** + * Get foo + * @return foo + **/ + + @Schema(description = "") + + public Boolean isFoo() { + return foo; + } + + + + public void setFoo(Boolean foo) { + this.foo = foo; + } + + public AllOfSubCategoryCategory bar(Integer bar) { + + this.bar = bar; + return this; + } + + /** + * Get bar + * @return bar + **/ + + @Schema(description = "") + + public Integer getBar() { + return bar; + } + + + + public void setBar(Integer bar) { + this.bar = bar; + } + + public AllOfSubCategoryCategory beer(String beer) { + + this.beer = beer; + return this; + } + + /** + * Get beer + * @return beer + **/ + + @Schema(description = "") + + public String getBeer() { + return beer; + } + + + + public void setBeer(String beer) { + this.beer = beer; + } + + public AllOfSubCategoryCategory drunk(User drunk) { + + this.drunk = drunk; + return this; + } + + /** + * Get drunk + * @return drunk + **/ + + @Schema(description = "") + +@Valid + public User getDrunk() { + return drunk; + } + + + + public void setDrunk(User drunk) { + this.drunk = drunk; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AllOfSubCategoryCategory allOfSubCategoryCategory = (AllOfSubCategoryCategory) o; + return Objects.equals(this.foo, allOfSubCategoryCategory.foo) && + Objects.equals(this.bar, allOfSubCategoryCategory.bar) && + Objects.equals(this.beer, allOfSubCategoryCategory.beer) && + Objects.equals(this.drunk, allOfSubCategoryCategory.drunk) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(foo, bar, beer, drunk, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AllOfSubCategoryCategory {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).append("\n"); + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" beer: ").append(toIndentedString(beer)).append("\n"); + sb.append(" drunk: ").append(toIndentedString(drunk)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryPetsItems.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryPetsItems.java new file mode 100644 index 00000000000..d89a7241dc1 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllOfSubCategoryPetsItems.java @@ -0,0 +1,62 @@ +package io.swagger.model; + +import java.util.Objects; +import io.swagger.model.Category; +import io.swagger.model.Pet; +import io.swagger.model.Tag; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * AllOfSubCategoryPetsItems + */ +@Validated +@NotUndefined + + + +public class AllOfSubCategoryPetsItems extends Pet { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AllOfSubCategoryPetsItems {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllPetsResponse.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllPetsResponse.java new file mode 100644 index 00000000000..4fdf883aada --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/AllPetsResponse.java @@ -0,0 +1,60 @@ +package io.swagger.model; + +import java.util.Objects; +import java.util.ArrayList; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * AllPetsResponse + */ +@Validated +@NotUndefined + + + +public class AllPetsResponse extends ArrayList { + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + return true; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AllPetsResponse {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Cat.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Cat.java new file mode 100644 index 00000000000..c509d9e8269 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Cat.java @@ -0,0 +1,129 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.model.Category; +import io.swagger.model.Pet; +import io.swagger.model.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Cat + */ +@Validated +@NotUndefined + + + +public class Cat extends Pet implements OneOfAllPetsResponseItems, OneOfSinglePetResponsePet { + @JsonProperty("hunts") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Boolean hunts = null; + + @JsonProperty("age") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Integer age = null; + + + public Cat hunts(Boolean hunts) { + + this.hunts = hunts; + return this; + } + + /** + * Get hunts + * @return hunts + **/ + + @Schema(description = "") + + public Boolean isHunts() { + return hunts; + } + + + + public void setHunts(Boolean hunts) { + this.hunts = hunts; + } + + public Cat age(Integer age) { + + this.age = age; + return this; + } + + /** + * Get age + * @return age + **/ + + @Schema(description = "") + + public Integer getAge() { + return age; + } + + + + public void setAge(Integer age) { + this.age = age; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(this.hunts, cat.hunts) && + Objects.equals(this.age, cat.age) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(hunts, age, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" hunts: ").append(toIndentedString(hunts)).append("\n"); + sb.append(" age: ").append(toIndentedString(age)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Category.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Category.java new file mode 100644 index 00000000000..d3d6e719681 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Category.java @@ -0,0 +1,123 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Category + */ +@Validated +@NotUndefined + + + +public class Category { + @JsonProperty("id") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long id = null; + + @JsonProperty("name") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String name = null; + + + public Category id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + + @Schema(description = "") + + public Long getId() { + return id; + } + + + + public void setId(Long id) { + this.id = id; + } + + public Category name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + + @Schema(description = "") + + public String getName() { + return name; + } + + + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Category category = (Category) o; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Dog.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Dog.java new file mode 100644 index 00000000000..113b789c351 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Dog.java @@ -0,0 +1,163 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.model.Category; +import io.swagger.model.Pet; +import io.swagger.model.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Dog + */ +@Validated +@NotUndefined + + + +public class Dog extends Pet implements OneOfAllPetsResponseItems, OneOfSinglePetResponsePet { + @JsonProperty("bark") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Boolean bark = null; + + /** + * Gets or Sets breed + */ + public enum BreedEnum { + DINGO("Dingo"), + + HUSKY("Husky"), + + RETRIEVER("Retriever"), + + SHEPHERD("Shepherd"); + + private String value; + + BreedEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static BreedEnum fromValue(String text) { + for (BreedEnum b : BreedEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + @JsonProperty("breed") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private BreedEnum breed = null; + + + public Dog bark(Boolean bark) { + + this.bark = bark; + return this; + } + + /** + * Get bark + * @return bark + **/ + + @Schema(description = "") + + public Boolean isBark() { + return bark; + } + + + + public void setBark(Boolean bark) { + this.bark = bark; + } + + public Dog breed(BreedEnum breed) { + + this.breed = breed; + return this; + } + + /** + * Get breed + * @return breed + **/ + + @Schema(description = "") + + public BreedEnum getBreed() { + return breed; + } + + + + public void setBreed(BreedEnum breed) { + this.breed = breed; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(this.bark, dog.bark) && + Objects.equals(this.breed, dog.breed) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(bark, breed, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" bark: ").append(toIndentedString(bark)).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..103e766b0a2 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,154 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * ModelApiResponse + */ +@Validated +@NotUndefined + + + +public class ModelApiResponse { + @JsonProperty("code") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Integer code = null; + + @JsonProperty("type") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String type = null; + + @JsonProperty("message") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String message = null; + + + public ModelApiResponse code(Integer code) { + + this.code = code; + return this; + } + + /** + * Get code + * @return code + **/ + + @Schema(description = "") + + public Integer getCode() { + return code; + } + + + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse type(String type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + + @Schema(description = "") + + public String getType() { + return type; + } + + + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse message(String message) { + + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + + @Schema(description = "") + + public String getMessage() { + return message; + } + + + + public void setMessage(String message) { + this.message = message; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(this.code, _apiResponse.code) && + Objects.equals(this.type, _apiResponse.type) && + Objects.equals(this.message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/NullableEnumModel.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/NullableEnumModel.java new file mode 100644 index 00000000000..f97d3ba1e14 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/NullableEnumModel.java @@ -0,0 +1,124 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * NullableEnumModel + */ +@Validated +@NotUndefined + + + +public class NullableEnumModel { + /** + * Gets or Sets enumProp + */ + public enum EnumPropEnum { + A("a"), + + B("b"), + + NULL(null); + + private String value; + + EnumPropEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EnumPropEnum fromValue(String text) { + for (EnumPropEnum b : EnumPropEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + @JsonProperty("enumProp") + + private EnumPropEnum enumProp = null; + + + public NullableEnumModel enumProp(EnumPropEnum enumProp) { + + this.enumProp = enumProp; + return this; + } + + /** + * Get enumProp + * @return enumProp + **/ + + @Schema(description = "") + + public EnumPropEnum getEnumProp() { + + return enumProp; + } + + + + public void setEnumProp(EnumPropEnum enumProp) { + this.enumProp = enumProp; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NullableEnumModel nullableEnumModel = (NullableEnumModel) o; + return Objects.equals(this.enumProp, nullableEnumModel.enumProp); + } + + @Override + public int hashCode() { + return Objects.hash(enumProp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NullableEnumModel {\n"); + + sb.append(" enumProp: ").append(toIndentedString(enumProp)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfAllPetsResponseItems.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfAllPetsResponseItems.java new file mode 100644 index 00000000000..d394f7f50b1 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfAllPetsResponseItems.java @@ -0,0 +1,19 @@ +package io.swagger.model; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +/** +* OneOfAllPetsResponseItems +*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat") +}) +public interface OneOfAllPetsResponseItems { + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfSinglePetResponsePet.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfSinglePetResponsePet.java new file mode 100644 index 00000000000..4eae5ac9c70 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/OneOfSinglePetResponsePet.java @@ -0,0 +1,19 @@ +package io.swagger.model; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +/** +* OneOfSinglePetResponsePet +*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "Dog"), + @JsonSubTypes.Type(value = Cat.class, name = "Cat") +}) +public interface OneOfSinglePetResponsePet { + +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Order.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Order.java new file mode 100644 index 00000000000..b8a847ceac4 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Order.java @@ -0,0 +1,282 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.OffsetDateTime; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Order + */ +@Validated +@NotUndefined + + + +public class Order { + @JsonProperty("id") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long id = null; + + @JsonProperty("petId") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long petId = null; + + @JsonProperty("quantity") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Integer quantity = null; + + @JsonProperty("shipDate") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private OffsetDateTime shipDate = null; + + /** + * Order Status + */ + public enum StatusEnum { + PLACED("placed"), + + APPROVED("approved"), + + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + @JsonProperty("status") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private StatusEnum status = null; + + @JsonProperty("complete") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Boolean complete = false; + + + public Order id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + + @Schema(description = "") + + public Long getId() { + return id; + } + + + + public void setId(Long id) { + this.id = id; + } + + public Order petId(Long petId) { + + this.petId = petId; + return this; + } + + /** + * Get petId + * @return petId + **/ + + @Schema(description = "") + + public Long getPetId() { + return petId; + } + + + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order quantity(Integer quantity) { + + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity + **/ + + @Schema(description = "") + + public Integer getQuantity() { + return quantity; + } + + + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order shipDate(OffsetDateTime shipDate) { + + this.shipDate = shipDate; + return this; + } + + /** + * Get shipDate + * @return shipDate + **/ + + @Schema(description = "") + +@Valid + public OffsetDateTime getShipDate() { + return shipDate; + } + + + + public void setShipDate(OffsetDateTime shipDate) { + this.shipDate = shipDate; + } + + public Order status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Order Status + * @return status + **/ + + @Schema(description = "Order Status") + + public StatusEnum getStatus() { + return status; + } + + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order complete(Boolean complete) { + + this.complete = complete; + return this; + } + + /** + * Get complete + * @return complete + **/ + + @Schema(description = "") + + public Boolean isComplete() { + return complete; + } + + + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Order order = (Order) o; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); + } + + @Override + public int hashCode() { + return Objects.hash(id, petId, quantity, shipDate, status, complete); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Pet.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Pet.java new file mode 100644 index 00000000000..36faed747f5 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Pet.java @@ -0,0 +1,294 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.model.Category; +import io.swagger.model.Tag; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.ArrayList; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Pet + */ +@Validated +@NotUndefined + + + +public class Pet { + @JsonProperty("id") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long id = null; + + @JsonProperty("category") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Category category = null; + + @JsonProperty("name") + + private String name = null; + + @JsonProperty("photoUrls") + @Valid + private List photoUrls = new ArrayList<>(); + @JsonProperty("tags") + @Valid + private List tags = null; + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE("available"), + + PENDING("pending"), + + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + } + @JsonProperty("status") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private StatusEnum status = null; + + + public Pet id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + + @Schema(description = "") + + public Long getId() { + return id; + } + + + + public void setId(Long id) { + this.id = id; + } + + public Pet category(Category category) { + + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + + @Schema(description = "") + +@Valid + public Category getCategory() { + return category; + } + + + + public void setCategory(Category category) { + this.category = category; + } + + public Pet name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + + @Schema(example = "doggie", required = true, description = "") + + @NotNull + public String getName() { + return name; + } + + + + public void setName(String name) { + + this.name = name; + } + + public Pet photoUrls(List photoUrls) { + + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get photoUrls + * @return photoUrls + **/ + + @Schema(required = true, description = "") + + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + + + public void setPhotoUrls(List photoUrls) { + + this.photoUrls = photoUrls; + } + + public Pet tags(List tags) { + + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + + @Schema(description = "") + @Valid + public List getTags() { + return tags; + } + + + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * pet status in the store + * @return status + **/ + + @Schema(description = "pet status in the store") + + public StatusEnum getStatus() { + return status; + } + + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Pet pet = (Pet) o; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/PetPetIdBody.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/PetPetIdBody.java new file mode 100644 index 00000000000..f85b513a857 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/PetPetIdBody.java @@ -0,0 +1,123 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * PetPetIdBody + */ +@Validated +@NotUndefined + + + +public class PetPetIdBody { + @JsonProperty("name") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String name = null; + + @JsonProperty("status") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String status = null; + + + public PetPetIdBody name(String name) { + + this.name = name; + return this; + } + + /** + * Updated name of the pet + * @return name + **/ + + @Schema(description = "Updated name of the pet") + + public String getName() { + return name; + } + + + + public void setName(String name) { + this.name = name; + } + + public PetPetIdBody status(String status) { + + this.status = status; + return this; + } + + /** + * Updated status of the pet + * @return status + **/ + + @Schema(description = "Updated status of the pet") + + public String getStatus() { + return status; + } + + + + public void setStatus(String status) { + this.status = status; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetPetIdBody petPetIdBody = (PetPetIdBody) o; + return Objects.equals(this.name, petPetIdBody.name) && + Objects.equals(this.status, petPetIdBody.status); + } + + @Override + public int hashCode() { + return Objects.hash(name, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetPetIdBody {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SinglePetResponse.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SinglePetResponse.java new file mode 100644 index 00000000000..4b08d563adc --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SinglePetResponse.java @@ -0,0 +1,92 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * SinglePetResponse + */ +@Validated +@NotUndefined + + + +public class SinglePetResponse { + @JsonProperty("pet") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private OneOfSinglePetResponsePet pet = null; + + + public SinglePetResponse pet(OneOfSinglePetResponsePet pet) { + + this.pet = pet; + return this; + } + + /** + * Get pet + * @return pet + **/ + + @Schema(description = "") + + public OneOfSinglePetResponsePet getPet() { + return pet; + } + + + + public void setPet(OneOfSinglePetResponsePet pet) { + this.pet = pet; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SinglePetResponse singlePetResponse = (SinglePetResponse) o; + return Objects.equals(this.pet, singlePetResponse.pet); + } + + @Override + public int hashCode() { + return Objects.hash(pet); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SinglePetResponse {\n"); + + sb.append(" pet: ").append(toIndentedString(pet)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SubCategory.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SubCategory.java new file mode 100644 index 00000000000..8b0bca15455 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/SubCategory.java @@ -0,0 +1,163 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.model.Category; +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.ArrayList; +import java.util.List; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * SubCategory + */ +@Validated +@NotUndefined + + + +public class SubCategory { + @JsonProperty("category") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private AllOfSubCategoryCategory category = null; + + @JsonProperty("category2") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Category category2 = null; + + @JsonProperty("pets") + @Valid + private List pets = null; + + public SubCategory category(AllOfSubCategoryCategory category) { + + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + + @Schema(description = "") + + public AllOfSubCategoryCategory getCategory() { + return category; + } + + + + public void setCategory(AllOfSubCategoryCategory category) { + this.category = category; + } + + public SubCategory category2(Category category2) { + + this.category2 = category2; + return this; + } + + /** + * Get category2 + * @return category2 + **/ + + @Schema(description = "") + +@Valid + public Category getCategory2() { + return category2; + } + + + + public void setCategory2(Category category2) { + this.category2 = category2; + } + + public SubCategory pets(List pets) { + + this.pets = pets; + return this; + } + + public SubCategory addPetsItem(AllOfSubCategoryPetsItems petsItem) { + if (this.pets == null) { + this.pets = new ArrayList<>(); + } + this.pets.add(petsItem); + return this; + } + + /** + * Get pets + * @return pets + **/ + + @Schema(description = "") + + public List getPets() { + return pets; + } + + + + public void setPets(List pets) { + this.pets = pets; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SubCategory subCategory = (SubCategory) o; + return Objects.equals(this.category, subCategory.category) && + Objects.equals(this.category2, subCategory.category2) && + Objects.equals(this.pets, subCategory.pets); + } + + @Override + public int hashCode() { + return Objects.hash(category, category2, pets); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SubCategory {\n"); + + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" category2: ").append(toIndentedString(category2)).append("\n"); + sb.append(" pets: ").append(toIndentedString(pets)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Tag.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Tag.java new file mode 100644 index 00000000000..e1f35974dfc --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/Tag.java @@ -0,0 +1,123 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * Tag + */ +@Validated +@NotUndefined + + + +public class Tag { + @JsonProperty("id") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long id = null; + + @JsonProperty("name") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String name = null; + + + public Tag id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + + @Schema(description = "") + + public Long getId() { + return id; + } + + + + public void setId(Long id) { + this.id = id; + } + + public Tag name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + + @Schema(description = "") + + public String getName() { + return name; + } + + + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Tag tag = (Tag) o; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/User.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/User.java new file mode 100644 index 00000000000..7ae2b3ae9f9 --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/model/User.java @@ -0,0 +1,309 @@ +package io.swagger.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.validation.annotation.Validated; +import org.openapitools.jackson.nullable.JsonNullable; +import io.swagger.configuration.NotUndefined; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +/** + * User + */ +@Validated +@NotUndefined + + + +public class User { + @JsonProperty("id") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Long id = null; + + @JsonProperty("username") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String username = null; + + @JsonProperty("firstName") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String firstName = null; + + @JsonProperty("lastName") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String lastName = null; + + @JsonProperty("email") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String email = null; + + @JsonProperty("password") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String password = null; + + @JsonProperty("phone") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private String phone = null; + + @JsonProperty("userStatus") + + @JsonInclude(JsonInclude.Include.NON_ABSENT) // Exclude from JSON if absent + @JsonSetter(nulls = Nulls.FAIL) // FAIL setting if the value is null + private Integer userStatus = null; + + + public User id(Long id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + + @Schema(description = "") + + public Long getId() { + return id; + } + + + + public void setId(Long id) { + this.id = id; + } + + public User username(String username) { + + this.username = username; + return this; + } + + /** + * Get username + * @return username + **/ + + @Schema(description = "") + + public String getUsername() { + return username; + } + + + + public void setUsername(String username) { + this.username = username; + } + + public User firstName(String firstName) { + + this.firstName = firstName; + return this; + } + + /** + * Get firstName + * @return firstName + **/ + + @Schema(description = "") + + public String getFirstName() { + return firstName; + } + + + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User lastName(String lastName) { + + this.lastName = lastName; + return this; + } + + /** + * Get lastName + * @return lastName + **/ + + @Schema(description = "") + + public String getLastName() { + return lastName; + } + + + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User email(String email) { + + this.email = email; + return this; + } + + /** + * Get email + * @return email + **/ + + @Schema(description = "") + + public String getEmail() { + return email; + } + + + + public void setEmail(String email) { + this.email = email; + } + + public User password(String password) { + + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + + @Schema(description = "") + + public String getPassword() { + return password; + } + + + + public void setPassword(String password) { + this.password = password; + } + + public User phone(String phone) { + + this.phone = phone; + return this; + } + + /** + * Get phone + * @return phone + **/ + + @Schema(description = "") + + public String getPhone() { + return phone; + } + + + + public void setPhone(String phone) { + this.phone = phone; + } + + public User userStatus(Integer userStatus) { + + this.userStatus = userStatus; + return this; + } + + /** + * User Status + * @return userStatus + **/ + + @Schema(description = "User Status") + + public Integer getUserStatus() { + return userStatus; + } + + + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/springboot-4/src/main/resources/application.properties b/samples/server/petstore/springboot-4/src/main/resources/application.properties new file mode 100644 index 00000000000..10635f82b6c --- /dev/null +++ b/samples/server/petstore/springboot-4/src/main/resources/application.properties @@ -0,0 +1,3 @@ +springdoc.api-docs.path=/api-docs +server.servlet.contextPath=/ +server.port=8080 From ec98ee67045c4a30f44475ae6f885464db07a2bf Mon Sep 17 00:00:00 2001 From: Daniel Kmiecik Date: Thu, 26 Nov 2026 10:08:09 +0100 Subject: [PATCH 2/3] ci: bump GitHub Actions versions in springboot4 workflow checkout v7, setup-java v6 (temurin), upload-artifact v7, download-artifact v8. Co-Authored-By: Claude Sonnet 5.5 --- .../test-framework-v3-springboot4.yml | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-framework-v3-springboot4.yml b/.github/workflows/test-framework-v3-springboot4.yml index 0b697c7a7e9..cca6231be38 100644 --- a/.github/workflows/test-framework-v3-springboot4.yml +++ b/.github/workflows/test-framework-v3-springboot4.yml @@ -17,11 +17,12 @@ jobs: java: [ 11 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 with: ref: 3.0.0 - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v6 with: + distribution: temurin java-version: ${{ matrix.java }} - name: build codegen run: | @@ -31,12 +32,12 @@ jobs: mvn -q -B package -DskipTests -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -Dmaven.wagon.http.retryHandler.count=3 cp modules/swagger-codegen-cli/target/swagger-codegen-cli.jar codegen-cli - name: upload codegen cli - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: codegen-cli path: codegen-cli - name: upload test files - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: spring-custom-test-files path: samples/custom-tests/spring/v3/springboot4 @@ -56,12 +57,13 @@ jobs: generate_outcome: ${{ steps.outcome.outputs.generate_outcome }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 + - uses: actions/checkout@v7 + - uses: actions/setup-java@v6 with: + distribution: temurin java-version: ${{ matrix.java }} - name: Download codegen cli - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v8 with: name: codegen-cli - name: generate @@ -78,18 +80,18 @@ jobs: echo "generate_outcome=${{ steps.generate.outcome }}" >> $GITHUB_OUTPUT echo ${{ steps.generate.outcome }} > generate_outcome_${{ env.JOB_NAME }} - name: upload generate outcome - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: ${{ env.JOB_NAME }}generate_outcome path: generate_outcome_${{ env.JOB_NAME }} - name: upload generate logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: ${{ env.JOB_NAME }}generate_logs path: ${{ steps.generate.outputs.logs }} - name: upload generated code if: contains(steps.generate.outcome, 'success') - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: ${{ env.JOB_NAME }}generated path: ${{ steps.generate.outputs.path }} @@ -112,28 +114,29 @@ jobs: ##### END DYNAMIC: Dependent on build environment ############################################### steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v7 - name: Download artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v8 with: name: ${{ env.JOB_NAME }}generated path: generated/${{ env.JOB_NAME }} - name: Download logs - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v8 with: name: ${{ env.JOB_NAME }}generate_logs ############################################### ##### DYNAMIC: Dependent on build environment ############################################### - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v1 + uses: actions/setup-java@v6 with: + distribution: temurin java-version: ${{ matrix.java-version }} ############################################### ##### END DYNAMIC: Dependent on build environment ############################################### - name: Download Java Test Files - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v8 with: name: spring-custom-test-files path: spring-custom-test-files @@ -162,12 +165,12 @@ jobs: echo "build_outcome=${{ steps.build.outcome }}" >> $GITHUB_OUTPUT echo ${{ steps.build.outcome }} > ${{ env.JOB_NAME }}build_outcome - name: upload build outcome - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: ${{ env.JOB_NAME }}build_outcome-java${{ matrix.java-version }} path: ${{ env.JOB_NAME }}build_outcome - name: upload logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v7 with: name: ${{ env.JOB_NAME }}logs-java${{ matrix.java-version }} path: ${{ steps.build.outputs.logs }} From 3c888dfa119196eab4de429e714449643538e244 Mon Sep 17 00:00:00 2001 From: Daniel Kmiecik Date: Thu, 26 Nov 2026 10:54:53 +0100 Subject: [PATCH 3/3] fix: comments after review --- .github/workflows/test-framework-v3-springboot4.yml | 5 ++++- .../server/petstore/springboot-4/.swagger-codegen/VERSION | 2 +- samples/server/petstore/springboot-4/README.md | 2 +- samples/server/petstore/springboot-4/pom.xml | 4 ++-- .../src/main/java/io/swagger/api/DefaultApi.java | 2 +- .../springboot-4/src/main/java/io/swagger/api/PetApi.java | 2 +- .../springboot-4/src/main/java/io/swagger/api/StoreApi.java | 2 +- .../springboot-4/src/main/java/io/swagger/api/UserApi.java | 2 +- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-framework-v3-springboot4.yml b/.github/workflows/test-framework-v3-springboot4.yml index cca6231be38..743f103f739 100644 --- a/.github/workflows/test-framework-v3-springboot4.yml +++ b/.github/workflows/test-framework-v3-springboot4.yml @@ -3,7 +3,6 @@ name: Test Framework V3 Springboot4 (Spring Boot 4 / Jackson 3) on: # execute on demand workflow_dispatch: - branches: ["3.0.0"] jobs: @@ -58,6 +57,8 @@ jobs: steps: - uses: actions/checkout@v7 + with: + ref: 3.0.0 - uses: actions/setup-java@v6 with: distribution: temurin @@ -115,6 +116,8 @@ jobs: ############################################### steps: - uses: actions/checkout@v7 + with: + ref: 3.0.0 - name: Download artifacts uses: actions/download-artifact@v8 with: diff --git a/samples/server/petstore/springboot-4/.swagger-codegen/VERSION b/samples/server/petstore/springboot-4/.swagger-codegen/VERSION index cc5c6b79360..37e7ae413a0 100644 --- a/samples/server/petstore/springboot-4/.swagger-codegen/VERSION +++ b/samples/server/petstore/springboot-4/.swagger-codegen/VERSION @@ -1 +1 @@ -3.0.86-SNAPSHOT \ No newline at end of file +3.0.87-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/springboot-4/README.md b/samples/server/petstore/springboot-4/README.md index 47a54b75f9b..065cd25a714 100644 --- a/samples/server/petstore/springboot-4/README.md +++ b/samples/server/petstore/springboot-4/README.md @@ -8,7 +8,7 @@ This server was generated by the [swagger-codegen](https://github.com/swagger-ap By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the SpringBoot framework. -Requirements: Java 21+ (Spring Boot 4 needs Java 17 or newer). +Requirements: Java 17+ (Spring Boot 4 needs Java 17 or newer). The generated API interfaces carry default methods (the `java8` option is always on for this library). JSON (de)serialization uses Jackson 3 (`tools.jackson.*`); Jackson annotations stay on `com.fasterxml.jackson.annotation`. diff --git a/samples/server/petstore/springboot-4/pom.xml b/samples/server/petstore/springboot-4/pom.xml index 215d7ff853c..b79108eceaa 100644 --- a/samples/server/petstore/springboot-4/pom.xml +++ b/samples/server/petstore/springboot-4/pom.xml @@ -7,9 +7,9 @@ 1.0.0 UTF-8 - 21 + 17 4.1.3 - 2.2.25 + 2.2.56 3.2.0 0.2.13 diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java index 97bdccb41d4..6554a607161 100644 --- a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/DefaultApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (3.0.87-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java index 606adfd5661..a1216cc9f8b 100644 --- a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/PetApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (3.0.87-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java index 2fb02223176..9ea7856f140 100644 --- a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/StoreApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (3.0.87-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ diff --git a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java index 11eba9e7533..ee22397529d 100644 --- a/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java +++ b/samples/server/petstore/springboot-4/src/main/java/io/swagger/api/UserApi.java @@ -1,5 +1,5 @@ /** - * NOTE: This class is auto generated by the swagger code generator program (3.0.86-SNAPSHOT). + * NOTE: This class is auto generated by the swagger code generator program (3.0.87-SNAPSHOT). * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */