This repository was archived by the owner on Dec 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,19 +68,32 @@ function compileInfo (postmanJson, optsInfo) {
6868function parseBody ( body = { } , method ) {
6969 // Swagger validation return an error if GET has body
7070 if ( [ 'GET' ] . includes ( method ) ) return { }
71- const { mode, raw } = body
71+ const { mode, raw, options } = body
7272 let content = { }
7373 switch ( mode ) {
74- case 'raw' :
75- content = {
76- 'application/json' : {
77- schema : {
78- type : 'object' ,
79- example : JSON . parse ( raw )
74+ case 'raw' : {
75+ const { raw : { language } } = options
76+ if ( language === 'json' ) {
77+ content = {
78+ 'application/json' : {
79+ schema : {
80+ type : 'object' ,
81+ example : JSON . parse ( raw )
82+ }
83+ }
84+ }
85+ } else {
86+ content = {
87+ 'application/json' : {
88+ schema : {
89+ type : 'string' ,
90+ example : raw
91+ }
8092 }
8193 }
8294 }
8395 break
96+ }
8497 case 'file' :
8598 content = {
8699 'text/plain' : { }
Original file line number Diff line number Diff line change 22 "info" : {
33 "_postman_id" : " 2a45baa5-352f-4831-8483-1a0fcbc7da37" ,
44 "name" : " Postman to OpenAPI" ,
5- "description" : " Mi super test collection from postman " ,
5+ "description" : " Mi super test collection from postman" ,
66 "schema" : " https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
77 },
88 "item" : [
99 {
10- "name" : " Create a user " ,
10+ "name" : " Create new User " ,
1111 "request" : {
1212 "method" : " POST" ,
1313 "header" : [],
3131 " users"
3232 ]
3333 },
34- "description" : " This is a post request with json body "
34+ "description" : " Create a new user into your amazing API "
3535 },
3636 "response" : []
3737 },
6262 }
6363 },
6464 "response" : []
65+ },
66+ {
67+ "name" : " Create a note" ,
68+ "request" : {
69+ "method" : " POST" ,
70+ "header" : [],
71+ "body" : {
72+ "mode" : " raw" ,
73+ "raw" : " This is an example Note" ,
74+ "options" : {
75+ "raw" : {
76+ "language" : " text"
77+ }
78+ }
79+ },
80+ "url" : {
81+ "raw" : " https://api.io/note" ,
82+ "protocol" : " https" ,
83+ "host" : [
84+ " api" ,
85+ " io"
86+ ],
87+ "path" : [
88+ " note"
89+ ]
90+ },
91+ "description" : " Just an example of text raw body"
92+ },
93+ "response" : []
6594 }
6695 ],
6796 "event" : [
88117 ],
89118 "variable" : [
90119 {
91- "id" : " cfcda50b-827a-4a48-8059-1344d044cba7 " ,
120+ "id" : " d04439bd-c604-4758-bde2-3c873140f38c " ,
92121 "key" : " version" ,
93122 "value" : " 1.1.0"
94123 }
Original file line number Diff line number Diff line change 11openapi : 3.0.0
22info :
33 title : Postman to OpenAPI
4- description : ' Mi super test collection from postman '
4+ description : Mi super test collection from postman
55 version : 1.1.0
66paths :
77 /users :
88 post :
99 tags :
1010 - default
11- summary : Create a user
12- description : This is a post request with json body
11+ summary : Create new User
12+ description : Create a new user into your amazing API
1313 requestBody :
1414 content :
1515 application/json :
@@ -38,3 +38,20 @@ paths:
3838 description : Successful response
3939 content :
4040 application/json : {}
41+ /note :
42+ post :
43+ tags :
44+ - default
45+ summary : Create a note
46+ description : Just an example of text raw body
47+ requestBody :
48+ content :
49+ application/json :
50+ schema :
51+ type : string
52+ example : This is an example Note
53+ responses :
54+ ' 200 ' :
55+ description : Successful response
56+ content :
57+ application/json : {}
You can’t perform that action at this time.
0 commit comments