acouvreur / openapi-generator-java-wiremock-demo

This repository shows how to use the `java-wiremock` generator inside of the openapi-generator project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenAPI Generator - java-wiremcok generator demo

This project covers:

  • Why ? The problem it solves
  • How ? How to use the java-wiremock generator
  • When ? The uses cases and situations where it's useful

Why ?

The generator aims to solve multiples issues when creating stubs for APIs you're consuming.

  1. Misimplementation - You may wrongly implement your stub (missing header, wrong status code, etc.)
  2. Out of date - You'll have to keep the stubs up to date with the latest changes (new mandatory query parameter, removed header, etc.)
  3. Too many endpoints - If you want to test all the possible use cases from the remote API, you'll have to create a stub for each endpoint and each status code.

How ?

See the related pull requests:

TODO: Add how to use it with code

When ?

1. When writing an integration test

Whenever you write an integration test with an API you should mock the server.

You should mock the server to properly ensure correctness of:

  • path parameters/query parameters
  • headers (authorization, content type, accept, etc.)
  • serialization/deserialization

Mocking the client tides you to:

  • client internals
    • exceptions
    • fault
    • etc.
  • the client itself

2. When distributing a Client SDK

When you distribute a Client SDK, you can provide to your users a test package which allows them to quickly setup mock expectations.

3. When testing legacy clients

Go back to point 1, but this time, the client is already there and might be... TODO: Complete this

About

This repository shows how to use the `java-wiremock` generator inside of the openapi-generator project.


Languages

Language:Java 100.0%