@@ -129,7 +129,7 @@ Return nil if the authentication is not Basic or if the base64 is invalid."
129129 " Replace variables in a string, using verb syntax.
130130
131131STRING any string that can contain variables with format \" {{variable}}\" .
132- VARIABLES is a alist with Postman environment variables."
132+ VARIABLES is a alist with Postman variables."
133133 (if impostman-use-variables
134134 (replace-regexp-in-string
135135 " {{\\ ([^}]+\\ )}}" " {{(verb-var \\ 1)}}" (or string " " ))
@@ -146,7 +146,7 @@ VARIABLES is a alist with Postman environment variables."
146146
147147NAME is the collection name.
148148DESCRIPTION is the collection description.
149- VARIABLES is a alist with Postman environment variables."
149+ VARIABLES is a alist with Postman variables."
150150 (ignore variables)
151151 (concat
152152 " * " name " :verb:" " \n "
@@ -157,7 +157,8 @@ VARIABLES is a alist with Postman environment variables."
157157
158158LEVEL is the level.
159159NAME is the item name.
160- DESCRIPTION is the item description."
160+ DESCRIPTION is the item description.
161+ VARIABLES is a alist with Postman variables."
161162 (ignore variables)
162163 (concat
163164 (if (<= level 2 ) " \n " " " )
@@ -171,10 +172,11 @@ DESCRIPTION is the request description.
171172METHOD is the HTTP method.
172173URL is the URL.
173174HEADERS is an alist with HTTP headers.
174- BODY is the request body."
175+ BODY is the request body.
176+ VARIABLES is a alist with Postman variables."
175177 (ignore variables)
176178 (let (list-headers)
177- (dolist (header headers)
179+ (dolist (header ( nreverse headers) )
178180 (let* ((header-name (car header))
179181 (header-value (cdr header))
180182 (new-value header-value))
@@ -199,10 +201,10 @@ BODY is the request body."
199201 " Format the verb footer.
200202
201203NAME is the collection name.
202- VARIABLES is a alist with Postman environment variables."
204+ VARIABLES is a alist with Postman variables."
203205 (let (list-vars)
204206 (when impostman-use-variables
205- (dolist (var variables)
207+ (dolist (var ( nreverse variables) )
206208 (push
207209 (format " # eval: (verb-set-var \" %s \" \" %s \" ) " (car var) (cdr var))
208210 list-vars)))
@@ -217,14 +219,16 @@ VARIABLES is a alist with Postman environment variables."
217219 " # End:\n " )))
218220
219221(defun impostman-output-verb-end (variables )
220- " Function evaluated at the end."
222+ " Function evaluated at the end.
223+
224+ VARIABLES is a alist with Postman variables."
221225 (when (fboundp 'org-mode )
222226 (org-mode ))
223227 (when (fboundp 'verb-mode )
224228 (verb-mode))
225229 ; ; evaluate variables now
226230 (when (and impostman-use-variables (fboundp 'verb-set-var ))
227- (dolist (var variables)
231+ (dolist (var ( nreverse variables) )
228232 (verb-set-var (car var) (cdr var)))))
229233
230234; ; restclient output
@@ -253,7 +257,7 @@ DESCRIPTION is the collection description.
253257VARIABLES is a alist with Postman environment variables."
254258 (let (list-vars)
255259 (when impostman-use-variables
256- (dolist (var variables)
260+ (dolist (var ( nreverse variables) )
257261 (push (format " :%s = %s " (car var) (cdr var)) list-vars)))
258262 (concat
259263 " # -*- restclient -*-\n "
@@ -286,7 +290,7 @@ HEADERS is an alist with HTTP headers.
286290BODY is the request body."
287291 (ignore variables)
288292 (let (list-variables list-headers)
289- (dolist (header headers)
293+ (dolist (header ( nreverse headers) )
290294 (let* ((header-name (car header))
291295 (header-value (cdr header))
292296 (new-value header-value))
@@ -381,7 +385,7 @@ HEADER is a vector with hash tables."
381385 (key (gethash " key" header-item " " ))
382386 (value (gethash " value" header-item " " )))
383387 (push (cons key value) headers)))
384- ( nreverse headers) ))
388+ headers))
385389
386390(defun impostman--build-auth-query-string (auth )
387391 " Return query string parameter to add for authentication as an alist, for
@@ -424,25 +428,28 @@ QUERY-STRING is nil or an alist with query strings to add."
424428 url)
425429
426430(defun impostman--build-variables (values )
427- " Return alist with variables using values from Postman environment.
431+ " Return alist with variables using values from Postman collection and
432+ environment.
428433
429- VALUES is the \" values\" read from environment (vector)."
434+ VALUES is the \" variable\" read from collection (vector) or \" values\" read
435+ from environment (vector) (or concatenation of both)."
430436 (let (variables)
431437 (dotimes (i (length (or values [])))
432438 (let* ((item (elt values i))
433439 (key (gethash " key" item " " ))
434440 (value (gethash " value" item " " ))
435- (enabled (equal t (gethash " enabled" item t ))))
436- (when enabled
441+ (enabled (equal t (gethash " enabled" item t )))
442+ (disabled (equal t (gethash " disabled" item nil ))))
443+ (when (and enabled (not disabled))
437444 (push (cons key value) variables))))
438- ( nreverse variables) ))
445+ variables))
439446
440447(defun impostman--parse-item (items level variables output-alist )
441448 " Parse a Postman collection item.
442449
443450ITEMS is the \" item\" read from collection (vector).
444451LEVEL is the level.
445- VARIABLES is a alist with Postman environment variables.
452+ VARIABLES is a alist with Postman variables.
446453OUTPUT-ALIST is an alist with the output callbacks."
447454 (dotimes (i (length items))
448455 (let* ((item (elt items i))
@@ -467,7 +474,7 @@ OUTPUT-ALIST is an alist with the output callbacks."
467474 (gethash " url" request (make-hash-table )) " " ))
468475 (auth-headers (impostman--build-auth-headers auth))
469476 (other-headers (impostman--build-headers header))
470- (headers (append auth -headers other -headers))
477+ (headers (append other -headers auth -headers))
471478 (replace-vars (alist-get 'replace-vars output-alist)))
472479 (setq url (impostman--add-query-string-items-to-url
473480 url
@@ -496,16 +503,18 @@ OUTPUT-ALIST is an alist with the output callbacks."
496503 (gethash " info"
497504 collection (make-hash-table )) " " ))
498505 (item (gethash " item" collection []))
506+ (variable (gethash " variable" collection []))
499507 (values (gethash " values" environment []))
500- (variables (impostman--build-variables values)))
508+ (all-variables (impostman--build-variables (vconcat
509+ variable values))))
501510 (pop-to-buffer (generate-new-buffer (concat name " .org" )))
502- (funcall (alist-get 'init output-alist) variables)
511+ (funcall (alist-get 'init output-alist) all- variables)
503512 (insert (funcall (alist-get 'header output-alist)
504- name description variables))
505- (impostman--parse-item item 2 variables output-alist)
506- (insert (funcall (alist-get 'footer output-alist) name variables))
513+ name description all- variables))
514+ (impostman--parse-item item 2 all- variables output-alist)
515+ (insert (funcall (alist-get 'footer output-alist) name all- variables))
507516 (goto-char (point-min ))
508- (funcall (alist-get 'end output-alist) variables)
517+ (funcall (alist-get 'end output-alist) all- variables)
509518 values))
510519
511520;;;### autoload
0 commit comments