|
| 1 | +# Contributing Guide |
| 2 | + |
| 3 | +Thanks for your interest in improving **spring-boot-openapi-generics-clients**! |
| 4 | +This project showcases **type-safe, generics-aware OpenAPI clients** (Java 21, Spring Boot 3.4.x, OpenAPI Generator 7.x) with a `{ data, meta }` envelope and RFC 9457 Problem Details. |
| 5 | + |
| 6 | +> Be kind. Be constructive. See our [Code of Conduct](./CODE_OF_CONDUCT.md). |
| 7 | +
|
| 8 | +--- |
| 9 | + |
| 10 | +## Table of contents |
| 11 | + |
| 12 | +* [Questions & support](#questions--support) |
| 13 | +* [How to contribute](#how-to-contribute) |
| 14 | +* [Development setup](#development-setup) |
| 15 | +* [Project layout](#project-layout) |
| 16 | +* [Coding style & commits](#coding-style--commits) |
| 17 | +* [Testing & coverage](#testing--coverage) |
| 18 | +* [OpenAPI spec & client generation](#openapi-spec--client-generation) |
| 19 | +* [Pull Request checklist](#pull-request-checklist) |
| 20 | +* [Labels we use](#labels-we-use) |
| 21 | +* [Security](#security) |
| 22 | +* [License](#license) |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Questions & support |
| 27 | + |
| 28 | +* Have a question or idea? |
| 29 | + |
| 30 | + * Use **GitHub Discussions → *Ideas*** for design/roadmap talk (e.g., envelopes, nested containers). |
| 31 | + * Use **Discussions → *Q&A*** for “how do I…?” support. |
| 32 | +* Found a bug? Open an **Issue** with a minimal repro. |
| 33 | + |
| 34 | +Please search existing issues/discussions before opening a new one. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## How to contribute |
| 39 | + |
| 40 | +1. **Fork** the repo and create a feature branch: |
| 41 | + |
| 42 | + ```bash |
| 43 | + git checkout -b feature/scope-short-title |
| 44 | + ``` |
| 45 | +2. Make small, focused changes. |
| 46 | +3. Add/adjust tests and docs where it makes sense. |
| 47 | +4. Run the full build locally (see below). |
| 48 | +5. Open a PR to `main` with a clear description and checklist. |
| 49 | + |
| 50 | +> Tip: Small PRs with a tight scope are reviewed faster. |
| 51 | +
|
| 52 | +--- |
| 53 | + |
| 54 | +## Development setup |
| 55 | + |
| 56 | +**Prereqs** |
| 57 | + |
| 58 | +* Java 21 (Temurin recommended) |
| 59 | +* Maven 3.9+ |
| 60 | +* Docker (optional; for running the service in a container) |
| 61 | + |
| 62 | +**Build everything** |
| 63 | + |
| 64 | +```bash |
| 65 | +# From repo root |
| 66 | +mvn -q -ntp clean verify |
| 67 | +``` |
| 68 | + |
| 69 | +**Run server locally** |
| 70 | + |
| 71 | +```bash |
| 72 | +cd customer-service |
| 73 | +mvn spring-boot:run |
| 74 | +# http://localhost:8084/customer-service |
| 75 | +``` |
| 76 | + |
| 77 | +**Generate & build client locally** |
| 78 | + |
| 79 | +```bash |
| 80 | +cd customer-service-client |
| 81 | +# Make sure the server is running so the spec is reachable (or place your spec under src/main/resources) |
| 82 | +mvn -q clean install |
| 83 | +``` |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Project layout |
| 88 | + |
| 89 | +``` |
| 90 | +/customer-service # Spring Boot API producer (exposes OpenAPI 3.1) |
| 91 | +/customer-service-client # Generated Java client (RestClient + overlays) |
| 92 | +/docs # Adoption guides & GitHub Pages sources |
| 93 | +/.github/workflows # CI (build, tests, Codecov) |
| 94 | +/CODE_OF_CONDUCT.md # Community standards |
| 95 | +/README.md # Root docs (start here) |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Coding style & commits |
| 101 | + |
| 102 | +* **Java style**: keep it idiomatic and consistent with **Google Java Format**. |
| 103 | + Run your formatter locally if you touch code outside generated folders. |
| 104 | + |
| 105 | +* **Commit convention**: |
| 106 | + Use clear, descriptive prefixes for consistency and readability. |
| 107 | + Recommended prefixes: |
| 108 | + |
| 109 | + * `feature:` — for new features or enhancements |
| 110 | + * `bugfix:` — for bug fixes |
| 111 | + * `docs:` — for documentation changes |
| 112 | + * `chore:` — for maintenance or configuration updates |
| 113 | + * `refactor:` — for internal code restructuring |
| 114 | + * `test:` — for adding or updating tests |
| 115 | + * `ci:` — for continuous integration or workflow changes |
| 116 | + |
| 117 | + **Examples:** |
| 118 | + |
| 119 | + * `feature(client): support configurable container allow-list` |
| 120 | + * `bugfix(server): avoid NPE in schema enrichment for composed types` |
| 121 | + |
| 122 | +* Favor clear naming, small classes, and cohesive tests that verify a single behavior. |
| 123 | +--- |
| 124 | + |
| 125 | +## Testing & coverage |
| 126 | + |
| 127 | +Run unit + integration tests: |
| 128 | + |
| 129 | +```bash |
| 130 | +# Module tests |
| 131 | +cd customer-service && mvn -q clean verify |
| 132 | +cd ../customer-service-client && mvn -q clean verify |
| 133 | +``` |
| 134 | + |
| 135 | +* Coverage is uploaded by CI via **Codecov** (see action config). |
| 136 | +* Client tests often use **MockWebServer** to verify Problem Details handling and envelope parsing. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## OpenAPI spec & client generation |
| 141 | + |
| 142 | +There are two common flows: |
| 143 | + |
| 144 | +### 1) Use the live spec from the local server |
| 145 | + |
| 146 | +1. Run `customer-service`. |
| 147 | +2. Pull the spec into the client module: |
| 148 | + |
| 149 | + ```bash |
| 150 | + cd customer-service-client |
| 151 | + curl -s http://localhost:8084/customer-service/v3/api-docs.yaml \ |
| 152 | + -o src/main/resources/customer-api-docs.yaml |
| 153 | + ``` |
| 154 | +3. Generate & compile: |
| 155 | + |
| 156 | + ```bash |
| 157 | + mvn -q clean install |
| 158 | + ``` |
| 159 | + |
| 160 | +### 2) Work against a committed spec |
| 161 | + |
| 162 | +* Edit or replace `customer-service-client/src/main/resources/customer-api-docs.yaml`. |
| 163 | +* Build as usual; the **Mustache overlays** generate thin wrappers: |
| 164 | + |
| 165 | + * `x-api-wrapper`, `x-api-wrapper-datatype` |
| 166 | + * When present, `x-data-container` + `x-data-item` enable nested generics like `Page<T>`. |
| 167 | +* `.openapi-generator-ignore` prevents duplicate DTOs (e.g., `Page`, `Meta`) if provided by the shared `common` package. |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +## Pull Request checklist |
| 172 | + |
| 173 | +Before hitting “Create pull request”: |
| 174 | + |
| 175 | +* [ ] Scope is minimal and focused. |
| 176 | +* [ ] Build passes locally: `mvn -q -ntp clean verify`. |
| 177 | +* [ ] Tests added/updated where it makes sense (esp. for envelope/generics or error handling). |
| 178 | +* [ ] Docs updated if behavior changes (`README.md`, `docs/adoption/*`, or Discussions). |
| 179 | +* [ ] No accidental changes to generated code outside intended overlays. |
| 180 | +* [ ] Title uses a helpful prefix (e.g., `feature:`, `bugfix:`, `docs:`). |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## Labels we use |
| 185 | + |
| 186 | +* **`enhancement`** – new capability, refactor that adds value, developer-experience. |
| 187 | +* **`bug`** – incorrect behavior, failing test, broken generation edge case. |
| 188 | +* **`documentation`** – README / Guides / GitHub Pages / examples. |
| 189 | +* **`good first issue`** – small, well-scoped tasks for first-time contributors. |
| 190 | +* **`help wanted`** – we’d love community input or PRs here. |
| 191 | +* **`discussion needed`** – needs design consensus before implementation. |
| 192 | + |
| 193 | +> Maintainers triage new issues with one or more of the above to guide contributors. |
| 194 | +
|
| 195 | +--- |
| 196 | + |
| 197 | +## Security |
| 198 | + |
| 199 | +If you discover a **security issue**, **do not** open a public issue. |
| 200 | +Email the maintainer at **[baris.sayli@gmail.com](mailto:baris.sayli@gmail.com)** with details. We’ll respond promptly. |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## License |
| 205 | + |
| 206 | +This project is licensed under **MIT** (see [LICENSE](./LICENSE)). |
| 207 | +By contributing, you agree your contributions are licensed under the same terms. |
0 commit comments