- 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/main
with the nameresources
. - Create
application.properties
file inside theresources
file. - In the
application.properties
file 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
static
undersrc/main/resources
. - Add an
index.html
file in thestatic
folder 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.html
file changeurl
field of theSwaggerUIBundle
initializer 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/test
folder. You can run them using the command:
mvn test