-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: completed the conversion from postman to asyncapi (#276)
- Loading branch information
Showing
14 changed files
with
343 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { transpile } from 'postman2openapi'; | ||
import { from_openapi_to_asyncapi } from './openapi'; | ||
import { ConvertPostmanFunction, PostmanToAsyncAPIOptions } from 'interfaces'; | ||
|
||
export const converters: Record<string, ConvertPostmanFunction > = { | ||
'3.0.0': from_postman_to_asyncapi | ||
} | ||
|
||
function from_postman_to_asyncapi(postman: any ,options:PostmanToAsyncAPIOptions ={}) { | ||
const perspective = options.perspective; | ||
const openapi = transpile(postman); | ||
const asyncapi = from_openapi_to_asyncapi(openapi , {perspective:perspective}); | ||
return asyncapi; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
info: | ||
name: Sample Postman Collection | ||
schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' | ||
item: | ||
- name: Sample Request | ||
request: | ||
method: GET | ||
header: [] | ||
url: | ||
raw: 'https://jsonplaceholder.typicode.com/posts/1' | ||
protocol: https | ||
host: | ||
- jsonplaceholder | ||
- typicode | ||
- com | ||
path: | ||
- posts | ||
- '1' | ||
response: [] | ||
- name: Sample POST Request | ||
request: | ||
method: POST | ||
header: | ||
- key: Content-Type | ||
value: application/json | ||
body: | ||
mode: raw | ||
raw: '{ "title": "foo", "body": "bar", "userId": 1 }' | ||
url: | ||
raw: 'https://jsonplaceholder.typicode.com/posts' | ||
protocol: https | ||
host: | ||
- jsonplaceholder | ||
- typicode | ||
- com | ||
path: | ||
- posts | ||
response: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
info: | ||
name: Headers and Authentication Test Collection | ||
schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json' | ||
item: | ||
- name: GET Request with Headers and Authentication | ||
request: | ||
method: GET | ||
header: | ||
- key: Authorization | ||
value: Bearer your_token | ||
- key: Accept | ||
value: application/json | ||
url: | ||
raw: 'https://example.com/api/authenticated' | ||
protocol: https | ||
host: | ||
- example | ||
- com | ||
path: | ||
- api | ||
- authenticated | ||
response: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
asyncapi: 3.0.0 | ||
info: | ||
title: Sample Postman Collection | ||
version: 1.0.0 | ||
servers: | ||
typicode_com: | ||
host: jsonplaceholder.typicode.com | ||
protocol: https | ||
channels: | ||
posts_1: | ||
address: /posts/1 | ||
messages: | ||
sampleRequestResponse200: | ||
name: sampleRequestResponse200 | ||
title: GET response 200 | ||
summary: '' | ||
posts: | ||
address: /posts | ||
messages: | ||
samplePostRequestRequest: | ||
name: samplePostRequestRequest | ||
title: POST request | ||
contentType: application/json | ||
payload: | ||
schemaFormat: application/vnd.oai.openapi;version=3.0.0 | ||
schema: | ||
type: object | ||
properties: | ||
body: | ||
type: string | ||
example: bar | ||
title: | ||
type: string | ||
example: foo | ||
userId: | ||
type: number | ||
example: 1 | ||
samplePostRequestResponse200: | ||
name: samplePostRequestResponse200 | ||
title: POST response 200 | ||
summary: '' | ||
operations: | ||
sampleRequest: | ||
action: receive | ||
channel: | ||
$ref: '#/channels/posts_1' | ||
summary: Sample Request | ||
description: Sample Request | ||
bindings: | ||
http: | ||
method: GET | ||
reply: | ||
channel: | ||
$ref: '#/channels/posts_1' | ||
messages: | ||
- $ref: '#/channels/posts_1/messages/sampleRequestResponse200' | ||
samplePostRequest: | ||
action: receive | ||
channel: | ||
$ref: '#/channels/posts' | ||
summary: Sample POST Request | ||
description: Sample POST Request | ||
bindings: | ||
http: | ||
method: POST | ||
messages: | ||
- $ref: '#/channels/posts/messages/samplePostRequestRequest' | ||
reply: | ||
channel: | ||
$ref: '#/channels/posts' | ||
messages: | ||
- $ref: '#/channels/posts/messages/samplePostRequestResponse200' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
asyncapi: 3.0.0 | ||
info: | ||
title: Headers and Authentication Test Collection | ||
version: 1.0.0 | ||
servers: | ||
example_com: | ||
host: example.com | ||
protocol: https | ||
channels: | ||
api_authenticated: | ||
address: /api/authenticated | ||
messages: | ||
getRequestWithHeadersAndAuthenticationResponse200: | ||
name: getRequestWithHeadersAndAuthenticationResponse200 | ||
title: GET response 200 | ||
summary: '' | ||
operations: | ||
getRequestWithHeadersAndAuthentication: | ||
action: receive | ||
channel: | ||
$ref: '#/channels/api_authenticated' | ||
summary: GET Request with Headers and Authentication | ||
description: GET Request with Headers and Authentication | ||
bindings: | ||
http: | ||
method: GET | ||
reply: | ||
channel: | ||
$ref: '#/channels/api_authenticated' | ||
messages: | ||
- $ref: >- | ||
#/channels/api_authenticated/messages/getRequestWithHeadersAndAuthenticationResponse200 |
Oops, something went wrong.