- Swagger Codegen version: 3.0.18
- Swagger Code Generators version: 1.0.19
- Generate server code with:
swagger-codegen generate -l jaxrs-jersey -i swagger-lyo-codegen-ext.yml -o target/server -t templates-server
- Inside the generated server code, create a folder at the same level as
src/mainwith the nameresources. - Create
application.propertiesfile inside theresourcesfile. - In the
application.propertiesfile specify the port according to the OpenAPI spec file:
server.port=8082
- Run the server with:
mvn spring-boot:run
- Check the server is running correctly by calling the following endpoints:
OpenAPI spec in JSON format: http://localhost:8082/adaptor-testing/services/openapi.json
Test Script Resource Shape: http://localhost:8082/adaptor-testing/services/resourceShapes/TestScript
Service provider: http://localhost:8082/adaptor-testing/services/provider/test
The generated project comes with a Maven plugin that downloads the Swagger UI resources into the target/static directory.
- Create a folder
staticundersrc/main/resources. - Add an
index.htmlfile in thestaticfolder with the following contents: https://raw.githubusercontent.com/swagger-api/swagger-samples/2.0/java/java-jersey2-configfile/src/main/webapp/index.html - In the newly created
index.htmlfile changeurlfield of theSwaggerUIBundleinitializer to the OpenAPI endpoint:http://localhost:8082/adaptor-testing/services/openapi.json - Download the resources with:
mvn clean package
- Start the server.
- Generate client library with:
swagger-codegen generate -l java -i swagger-lyo-codegen-ext.yml -o target/client --additional-properties library=jersey2 -t templates-client
- The library comes with a suite of tests, located in the
src/testfolder. You can run them using the command:
mvn test