@dryv/postman-collectionv0.1.0
Runnable Postman HTTP collection with generated request placeholders.
dryv pack add @dryv/postman-collection{%- macro scalar_example(value) -%}
{%- if value is none -%}null
{%- elif value.is.enum and value.property.enum.values -%}{{ value.property.enum.values[0].value_json }}
{%- elif value.is.boolean -%}false
{%- elif value.is.integer -%}1
{%- elif value.is.number -%}1
{%- elif value.is.uuid -%}"00000000-0000-4000-8000-000000000001"
{%- elif value.is.email -%}"[email protected]"
{%- elif value.is.url or value.is.uri -%}"https://example.com"
{%- elif value.is.date -%}"2026-01-01"
{%- elif value.is.time -%}"12:00:00"
{%- elif value.is.temporal -%}"2026-01-01T12:00:00Z"
{%- elif value.is.record -%}{}
{%- else -%}"example"
{%- endif -%}
{%- endmacro -%}
{%- macro field_example(field) -%}
{%- if field.default is not none and field.default.kind == 'value' -%}{{ field.default.value_json }}
{%- elif field.array is not none -%}[{{ scalar_example(field.value) }}]
{%- else -%}{{ scalar_example(field.value) }}
{%- endif -%}
{%- endmacro -%}
{%- macro binding_example(operation, binding) -%}
{%- set state = namespace(value='"example"') -%}
{%- if binding.port.field is not none -%}
{%- for field in operation.input.fields -%}
{%- if field.name.raw == binding.port.field.raw -%}{%- set state.value = field_example(field) | trim -%}{%- endif -%}
{%- endfor -%}
{%- elif operation.input is not none and operation.input.kind == 'schema' -%}{%- set state.value='{}' -%}
{%- endif -%}
{{- state.value -}}
{%- endmacro -%}
{%- macro raw_value(operation, binding) -%}
{%- set value = binding_example(operation, binding) | trim -%}
{{- value | replace('"', '') -}}
{%- endmacro -%}
{%- macro body_json(operation) -%}
{
{%- set first = namespace(value=true) -%}
{%- for binding in operation.facets.http.input_groups.body -%}
{%- if binding.port.field is none -%}
{%- for field in operation.input.fields %}
{% if not first.value %},{% endif %}{{ field.name.raw | tojson }}: {{ field_example(field) }}{% set first.value=false %}
{%- endfor -%}
{%- else -%}
{%- for field in operation.input.fields -%}
{%- if field.name.raw == binding.port.field.raw %}
{% if not first.value %},{% endif %}{{ field.name.raw | tojson }}: {{ field_example(field) }}{% set first.value=false %}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endfor %}
}
{%- endmacro -%}
{%- macro expected_codes(operation) -%}
[
{%- if operation.facets.http.outputs -%}
{%- for output in operation.facets.http.outputs %}{{ output.status }}{% if not loop.last %}, {% endif %}{% endfor %}
{%- else -%}200
{%- endif -%}
]
{%- endmacro -%}
{
"info": {
"name": {{ (application.name.title ~ " — Dryv") | tojson }},
"description": "Generated by Dryv from canonical Runtime IR. Placeholder request values are testing scaffolding only.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"variable": [
{
"key": "baseUrl",
"value": {{ pack.inputs.base_url | tojson }},
"type": "string"
}
],
"item": [
{%- for operation in operations %}
{%- set http = operation.facets.http %}
{%- set path = namespace(value=http.path.effective) %}
{%- for binding in http.input_groups.path %}
{%- set name = binding.name or binding.port.name.raw %}
{%- set path.value = path.value | replace('{' ~ name ~ '}', raw_value(operation, binding) | trim) %}
{%- endfor %}
{
"name": {{ operation.name.title | tojson }},
"request": {
"method": {{ http.method | tojson }},
"header": [
{%- set header_state = namespace(first=true) %}
{%- for binding in http.input_groups.header %}
{% if not header_state.first %},{% endif %}{
"key": {{ (binding.name or binding.port.name.raw) | tojson }},
"value": {{ (raw_value(operation, binding) | trim) | tojson }},
"type": "text"
}{% set header_state.first=false %}
{%- endfor %}
{%- if http.input_groups.cookie %}
{% if not header_state.first %},{% endif %}{
"key": "Cookie",
"value": "{% for binding in http.input_groups.cookie %}{{ binding.name or binding.port.name.raw }}={{ raw_value(operation, binding) | trim }}{% if not loop.last %}; {% endif %}{% endfor %}",
"type": "text"
}
{%- endif %}
],
"url": {
"raw": {{ ('{{baseUrl}}' ~ path.value) | tojson }},
"host": ["{{baseUrl}}"],
"path": [{% for segment in path.value.split('/') if segment %}{{ segment | tojson }}{% if not loop.last %}, {% endif %}{% endfor %}]
{%- if http.input_groups.query or http.input_groups.query_object %},
"query": [
{%- set query_state = namespace(first=true) %}
{%- for binding in http.input_groups.query %}
{% if not query_state.first %},{% endif %}{
"key": {{ (binding.name or binding.port.name.raw) | tojson }},
"value": {{ (raw_value(operation, binding) | trim) | tojson }}
}{% set query_state.first=false %}
{%- endfor %}
{%- for binding in http.input_groups.query_object %}
{%- if binding.port.field is none %}
{%- for field in operation.input.fields %}
{% if not query_state.first %},{% endif %}{
"key": {{ field.name.raw | tojson }},
"value": {{ ((field_example(field) | trim) | replace('"','')) | tojson }}
}{% set query_state.first=false %}
{%- endfor %}
{%- else %}
{% if not query_state.first %},{% endif %}{
"key": {{ (binding.name or binding.port.name.raw) | tojson }},
"value": {{ (raw_value(operation, binding) | trim) | tojson }}
}{% set query_state.first=false %}
{%- endif %}
{%- endfor %}
]
{%- endif %}
}
{%- if http.input_groups.body %},
"body": {
"mode": "raw",
"raw": {{ (body_json(operation) | trim) | tojson }},
"options": {"raw": {"language": "json"}}
}
{%- elif http.input_groups.form %},
"body": {
"mode": "urlencoded",
"urlencoded": [
{%- set form_state = namespace(first=true) %}
{%- for binding in http.input_groups.form %}
{%- if binding.port.field is none %}
{%- for field in operation.input.fields %}
{% if not form_state.first %},{% endif %}{
"key": {{ field.name.raw | tojson }},
"value": {{ ((field_example(field) | trim) | replace('"','')) | tojson }},
"type": "text"
}{% set form_state.first=false %}
{%- endfor %}
{%- else %}
{% if not form_state.first %},{% endif %}{
"key": {{ (binding.name or binding.port.name.raw) | tojson }},
"value": {{ (raw_value(operation, binding) | trim) | tojson }},
"type": "text"
}{% set form_state.first=false %}
{%- endif %}
{%- endfor %}
]
}
{%- elif http.input_groups.multipart %},
"body": {
"mode": "formdata",
"formdata": [
{
"key": "_dryv_notice",
"value": "Multipart file-part semantics are not yet represented by Dryv Runtime IR.",
"type": "text",
"disabled": true
}
]
}
{%- endif %}
},
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"const expected = {{ expected_codes(operation) | trim }};",
"pm.test('declared success status', function () {",
" pm.expect(expected).to.include(pm.response.code);",
"});"
]
}
}
]
}{% if not loop.last %},{% endif %}
{%- endfor %}
]
}