Hello,
I want to create a Postman collection from an API contract.
I need Postman creates samples based on the contract.
However, I’m unable to get Postman to load the parameter values (headers in this case) according to the examples.
Can you help me?
Here is the OAS contract (AI generated):
openapi: 3.0.4
info:
title: API with Examples
version: 1.0.0
paths:
/process:
post:
summary: Process data with multiple examples, referencing header from components
parameters:
- $ref: '#/components/parameters/RequestIDHeader'
requestBody:
description: Data to be processed
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RequestSchema'
examples:
example1:
$ref: '#/components/examples/Example1Request'
example2:
$ref: '#/components/examples/Example2Request'
example3:
$ref: '#/components/examples/Example3Request'
responses:
'200':
description: Data processed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ResponseSchema'
examples:
example1:
$ref: '#/components/examples/Example1Response'
example2:
$ref: '#/components/examples/Example2Response'
example3:
$ref: '#/components/examples/Example3Response'
'400':
description: Invalid input
content:
application/json:
schema:
type: object
properties:
error:
type: string
components:
parameters:
RequestIDHeader:
name: X-Request-ID
in: header
description: Unique identifier for the request
required: true
schema:
type: string
description: Schema for the X-Request-ID header
examples:
example1:
$ref: '#/components/examples/Example1Header'
example2:
$ref: '#/components/examples/Example2Header'
example3:
$ref: '#/components/examples/Example3Header'
schemas:
RequestSchema:
type: object
properties:
inputData:
type: string
description: The data string to process.
config:
type: object
properties:
setting:
type: integer
description: A configuration setting.
required:
- inputData
ResponseSchema:
type: object
properties:
outputData:
type: string
description: The result after processing.
status:
type: string
description: Status of the operation.
required:
- outputData
- status
examples:
Example1Header:
value: req-12345
Example1Request:
value:
inputData: "Hello World"
config:
setting: 1
Example1Response:
value:
outputData: "Processed: Hello World"
status: "success"
Example2Header:
value: req-67890
Example2Request:
value:
inputData: "Another piece of data"
config:
setting: 2
Example2Response:
value:
outputData: "Processed: Another piece of data"
status: "success"
Example3Header:
value: req-abcde
Example3Request:
value:
inputData: "Final example"
config:
setting: 3
optionalField: true # Example with an optional field
Example3Response:
value:
outputData: "Processed: Final example"
status: "completed"
Extra comments:
- I’m loading examples (not schemas)
- Example1
- Example2 (you can see that is the same value)