Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.4.0] - 2026-05-07

### Added
- Added support for OpenAPI 3.2.

## [2.3.0] - 2026-03-05

### Added
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ const endpointsParsed = require('./src/parser/endpoints.js')()
const authorizationTokens = []
_.forEach(endpointsParsed, function (endpointParsed, i) {
endpointsParsed[i].status = require('./src/parser/status.js')(endpointParsed.verb, endpointParsed.path)
if (endpointParsed.verb === 'POST' || endpointParsed.verb === 'PUT' || endpointParsed.verb === 'PATCH') {
const standardWriteMethods = ['POST', 'PUT', 'PATCH'];
const hasRequestBody = globalThis.definition.paths?.[endpointParsed.path]?.[endpointParsed.verb.toLowerCase()]?.requestBody;
if (standardWriteMethods.includes(endpointParsed.verb) || hasRequestBody) {
endpointsParsed[i].body = require('./src/parser/'+version+'/body.js')(endpointParsed.verb, endpointParsed.path)
endpointsParsed[i].consumes = require('./src/parser/'+version+'/consumes.js')(endpointParsed.verb, endpointParsed.path)
}
Expand Down
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openapi2postman",
"version": "2.3.0",
"version": "2.4.0",
"description": "openapi2postman",
"bin": {
"o2p": "index.js"
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 🛠️ Openapi2Postman ![Release](https://img.shields.io/badge/release-2.0.x-purple) ![OpenApi](https://img.shields.io/badge/-openapi-%23Clojure?style=flat&logo=openapiinitiative&logoColor=white) ![Postman](https://img.shields.io/badge/postman-FF6C37?style=flat&logo=postman&logoColor=white) [![NPM](https://img.shields.io/badge/npm-%23CB3837.svg?style=flat&logo=npm&logoColor=white)](https://www.npmjs.com/package/openapi2postman) [![License: LGPL v3](https://img.shields.io/badge/license-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
# 🛠️ Openapi2Postman ![Release](https://img.shields.io/badge/release-2.4.0-purple) ![OpenApi](https://img.shields.io/badge/-openapi-%23Clojure?style=flat&logo=openapiinitiative&logoColor=white) ![Postman](https://img.shields.io/badge/postman-FF6C37?style=flat&logo=postman&logoColor=white) [![NPM](https://img.shields.io/badge/npm-%23CB3837.svg?style=flat&logo=npm&logoColor=white)](https://www.npmjs.com/package/openapi2postman) [![License: LGPL v3](https://img.shields.io/badge/license-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)

**Openapi2Postman** creates automatic tests from Openapi 3.0 using postman format. Also, it creates environments files, depending of configuration.
Those collections can be importend in postan application. The tests includes tests for 2xx, 4xx... and tests to validate output formats.
**Openapi2Postman** creates automatic tests from OpenAPI 3.0, 3.1, and 3.2 specifications using postman format. Also, it creates environments files, depending of configuration.
Those collections can be imported in postman application. The tests includes tests for 2xx, 4xx... and tests to validate output formats.

<p align="center">
<a href="https://apiaddicts.org/">
Expand Down
290 changes: 290 additions & 0 deletions seeds/parserAuthorizationInitialOpenApi3.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
{
"openapi": "3.2.0",
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"description": "A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.2 specification",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "Swagger API Team",
"email": "apiteam@swagger.io",
"url": "http://swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"servers": [
{
"url": "http://petstore.swagger.io/api"
}
],
"security": [
{
"ApiKeyAuth": []
}
],
"paths": {
"/pets": {
"get": {
"security": [
{
"OAuth2": ["admin"]
}
],
"description": "Returns all pets from the system that the user has access to",
"operationId": "findPets",
"parameters": [
{
"name": "tags",
"in": "query",
"description": "tags to filter by",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
},
{
"name": "limit",
"in": "query",
"description": "maximum number of results to return",
"required": false,
"schema": {
"type": ["integer", "null"],
"format": "int32",
"minimum": 1
}
}
],
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Pet"
}
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"description": "Creates a new pet in the store. Duplicates are allowed",
"operationId": "addPet",
"requestBody": {
"description": "Pet to add to the store",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/NewPet"
}
}
}
},
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/pets/{id}": {
"get": {
"description": "Returns a pet based on a single ID",
"operationId": "findPetById",
"parameters": [
{
"$ref": "#/components/parameters/PetId"
}
],
"responses": {
"200": {
"description": "pet response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
}
},
"404": {
"description": "pet not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"delete": {
"description": "Deletes a single pet based on the ID supplied",
"operationId": "deletePet",
"parameters": [
{
"$ref": "#/components/parameters/PetId"
}
],
"responses": {
"204": {
"description": "pet deleted"
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"PetId": {
"name": "id",
"in": "path",
"description": "ID of pet",
"required": true,
"schema": {
"type": "integer",
"format": "int64",
"minimum": 1
}
}
},
"securitySchemes": {
"BasicAuth": {
"type": "http",
"scheme": "basic"
},
"BearerAuth": {
"type": "http",
"scheme": "bearer"
},
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-API-Key"
},
"OpenID": {
"type": "openIdConnect",
"openIdConnectUrl": "https://example.com/.well-known/openid-configuration"
},
"OAuth2": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://example.com/oauth/authorize",
"tokenUrl": "https://example.com/oauth/token",
"scopes": {
"read": "Grants read access",
"write": "Grants write access",
"admin": "Grants access to admin operations"
}
}
}
}
},
"schemas": {
"Pet": {
"allOf": [
{
"$ref": "#/components/schemas/NewPet"
},
{
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"unevaluatedProperties": false
}
]
},
"NewPet": {
"type": "object",
"required": ["name"],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"tag": {
"type": ["string", "null"],
"examples": ["dog", "cat", null]
},
"status": {
"type": "string",
"const": "available"
}
},
"unevaluatedProperties": false
},
"Error": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": ["code", "message"],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
},
"unevaluatedProperties": false
}
}
}
}
30 changes: 30 additions & 0 deletions seeds/parserBodyItemSchema3.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"openapi": "3.2.0",
"info": { "version": "1.0.0", "title": "Streaming API" },
"servers": [{ "url": "https://api.example.com/v1" }],
"paths": {
"/events": {
"get": {
"operationId": "streamEvents",
"responses": {
"200": {
"description": "Server-sent event stream",
"content": {
"application/jsonl": {
"itemSchema": {
"type": "object",
"required": ["id", "type"],
"properties": {
"id": { "type": "integer" },
"type": { "type": "string" }
}
}
}
}
}
}
}
}
},
"components": { "schemas": {} }
}
Loading