https://github.com/rspereiratech/openapi-collection-generator-samples
Sample Maven project demonstrating the openapi-collection-generator-maven-plugin — generates Postman and Insomnia collections from an OpenAPI 3.0 Pet Store specification.
https://github.com/rspereiratech/openapi-collection-generator-samples
api api-tools code-generation insomnia java java17 maven maven-plugin openapi openapi3 postman postman-collection rest-api sample swagger
Last synced: 4 days ago
JSON representation
Sample Maven project demonstrating the openapi-collection-generator-maven-plugin — generates Postman and Insomnia collections from an OpenAPI 3.0 Pet Store specification.
- Host: GitHub
- URL: https://github.com/rspereiratech/openapi-collection-generator-samples
- Owner: rspereiratech
- License: mit
- Created: 2026-05-08T15:57:32.000Z (25 days ago)
- Default Branch: master
- Last Pushed: 2026-05-08T17:13:44.000Z (25 days ago)
- Last Synced: 2026-05-08T18:41:21.830Z (25 days ago)
- Topics: api, api-tools, code-generation, insomnia, java, java17, maven, maven-plugin, openapi, openapi3, postman, postman-collection, rest-api, sample, swagger
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# OpenAPI Collection Generator – Samples
[](https://github.com/rspereiratech/openapi-collection-generator-samples/actions/workflows/build.yml)
[](LICENSE)
[](https://openjdk.org/projects/jdk/17/)
[](https://maven.apache.org/)
[](https://spec.openapis.org/oas/v3.0.3)
[](https://schema.postman.com/)
[](https://insomnia.rest/)
[](https://nowpayments.io/donation/rspereiratech)
Reference samples for the
[`openapi-collection-generator`](https://github.com/rspereiratech) ecosystem.
This repo demonstrates how to use each module — the **core** library, the
**Postman** generator, the **Insomnia** generator, and the **Maven plugin** —
against a small Pet Store OpenAPI 3.0 specification.
## What's in the box
```
.
├── pom.xml # Maven build, wires the Maven plugin
├── src/main/resources/
│ └── openapi.yaml # Sample Pet Store OpenAPI 3.0 spec
└── collections/ # Output produced by the plugin
├── PetStore_postman.json
├── PetStore_insomnia.json
└── PetStore.Production.environment.json
```
## Requirements
- Java 17+
- Maven 3.9+
- The other modules installed locally (run `mvn install` in each sibling repo,
or use the top-level `build-all.sh`):
- `openapi-collection-generator-parent`
- `openapi-collection-generator-core`
- `openapi-collection-generator-postman`
- `openapi-collection-generator-insomnia`
- `openapi-collection-generator-maven-plugin`
---
## 1. Using the Maven plugin (this project)
The simplest entry point. Add the plugin to your `pom.xml` and let it generate
both Postman and Insomnia collections during `generate-resources`:
```xml
io.github.rspereiratech
openapi-collection-generator-maven-plugin
1.0.0-SNAPSHOT
generate-collections
generate
POSTMAN
INSOMNIA
PetStore
${project.basedir}/collections
```
Run it:
```bash
mvn generate-resources
```
Or invoke the goal directly from the command line:
```bash
mvn io.github.rspereiratech:openapi-collection-generator-maven-plugin:generate \
-Dopenapi.spec=src/main/resources/openapi.yaml \
-Dopenapi.format=INSOMNIA \
-Dopenapi.outputDir=target/collections
```
Available configuration:
| Parameter | Property | Default |
|-------------------|---------------------------|------------------------------------------------------|
| `specFile` | `openapi.spec` | `${project.basedir}/src/main/resources/openapi.yaml` |
| `outputDirectory` | `openapi.outputDir` | `${project.build.directory}/generated-collections` |
| `formats` | `openapi.format` | `POSTMAN` |
| `collectionName` | `openapi.collectionName` | API title from the spec |
| `baseUrl` | `openapi.baseUrl` | First server URL from the spec |
---
## 2. Using the core library programmatically
When you need to embed the generator in your own tool (CLI, Gradle plugin,
custom build step), depend on the core module directly:
```xml
io.github.rspereiratech
openapi-collection-generator-core
1.0.0-SNAPSHOT
```
The single entry point is `CollectionGenerationOrchestrator`, which runs
the full pipeline (load → parse → generate → serialize → write):
```java
import io.github.rspereiratech.openapi.collection.generator.core.*;
GenerationRequest request = new GenerationRequest(
new File("src/main/resources/openapi.yaml"),
new File("build/collections"),
List.of(CollectionFormat.POSTMAN, CollectionFormat.INSOMNIA),
"PetStore"
);
CollectionGenerationOrchestrator orchestrator = /* wire components */;
List results = orchestrator.generate(request);
results.forEach(r -> System.out.println("Generated: " + r.collectionFile()));
```
Each `GenerationResult` exposes the produced collection file plus any
additional artifacts (e.g. environment files).
> **Tip:** when generating multiple formats in a single run, the file name
> pattern in `GenerationRequest` must include `{format}` so outputs don't
> overwrite each other.
---
## 3. Using the Postman generator directly
If you only care about Postman and want full control over wiring, use
`PostmanCollectionGenerator` from the Postman module:
```xml
io.github.rspereiratech
openapi-collection-generator-postman
1.0.0-SNAPSHOT
```
```java
import io.github.rspereiratech.openapi.collection.generator.postman.generator.PostmanCollectionGenerator;
PostmanCollectionGenerator generator = new PostmanCollectionGenerator(
operationGrouper,
collectionSerializer,
securityApplier,
serverEnvironmentGenerator
);
String collectionJson = generator.generate(openApi, generationConfig);
List environments =
generator.generateAdditionalFiles(openApi, generationConfig);
```
Output:
- `.postman_collection.json` — Postman Collection v2.1.0
- `.postman_environment.json` — one per OpenAPI server, with
`baseUrl` plus any required security variables as placeholders
---
## 4. Using the Insomnia generator directly
Same idea, for Insomnia v4:
```xml
io.github.rspereiratech
openapi-collection-generator-insomnia
1.0.0-SNAPSHOT
```
```java
import io.github.rspereiratech.openapi.collection.generator.insomnia.generator.InsomniaCollectionGenerator;
InsomniaCollectionGenerator generator = new InsomniaCollectionGenerator(
idGenerator,
insomniaRequestBuilder,
collectionSerializer,
/* ...remaining collaborators... */
);
String insomniaJson = generator.generate(openApi, generationConfig);
```
The resulting JSON can be imported directly via *Application → Preferences →
Data → Import Data* in Insomnia.
---
## Sample API
The included `openapi.yaml` describes a small **Pet Store** API with
endpoints for listing, creating, and retrieving pets — enough surface area
to exercise the most common request and response shapes (path parameters,
query parameters, JSON request bodies, multi-status responses).
## Support
[](https://nowpayments.io/donation/rspereiratech)
If this project saves you time, consider supporting development
via [NOWPayments](https://nowpayments.io/donation/rspereiratech).
Every contribution helps keep it maintained — thank you!
## License
Released under the [MIT License](LICENSE).
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup and PR guidelines, and
[SECURITY.md](SECURITY.md) for how to report security issues.