-
Notifications
You must be signed in to change notification settings - Fork 846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples are imported incorrectly from OpenAPI definition #6538
Comments
@ash007-postman More details, please. Can you share snippets of the OpenAPI spec that should be imported in a different way? |
@abhijitkane here you are. openapi: 3.0.2
info:
title: API
version: "1.0"
paths:
/core/status:
get:
summary: Get system status
operationId: getSystemStatus
responses:
'200':
description: "System status successfully retrieved case."
content:
'application/json':
schema:
$ref: '#/components/schemas/SystemStatusModel'
example:
$ref: '#/components/examples/GetSystemStatusResponseExample/value'
components:
schemas:
SystemStatusModel:
type: object
required:
- isDayClosed
properties:
version:
description: "Current version of API build."
type: string
uptime:
description: "Uptime of service in minutes."
type: integer
isDayClosed:
description: "End of the day flag."
type: boolean
example: {
"version": "0.4.0",
"uptime": 2837,
"isDayClosed": true
}
examples:
GetSystemStatusResponseExample:
summary: Get system status response example
description: "This is an example of get system status operation response in case of system status successfully retrieved. Send with HTTP status code 200 OK."
value: |-
{
"version": "0.4.0",
"uptime": 2837,
"isDayClosed": true
} Just import it in Postman, then go to the request example and you'll get: {
"$ref": "#/components/examples/GetSystemStatusResponseExample/value"
} |
@kholmukhamedovme This PR (https://github.com/postmanlabs/openapi-to-postman/pull/62/files) should fix the problem. We'll include this in the next release of Postman. Thanks for reporting this. |
Hey, @abhijitkane! I was wrong. I have been writing an invalid OpenAPI definition for examples as SmartBear support says:
But although, if you look at OpenAPI specification there is a Media Type Object which may contain |
I was wrong again. If I use single
If I use multiple
If I try to use both of them:
So just leave as is. I mean add this PR to release. |
Might be the same issue: from a OpenAPI spec like this: paths:
"/services/deployments":
post:
tags:
- "Register"
summary: ""
description: ""
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "ApplicationInstance"
required: true
schema:
$ref: "#/definitions/ApplicationInstance"
...
definitions:
ApplicationInstance:
type: "object"
properties:
InstanceName:
type: "string"
example: "Test"
InstanceId:
type: "string"
example: "bf40055d-8d9c-45db-a9e5-ddb30e0d0846"
InstanceURL:
type: "string"
example: "https://instance.url/"
... The POST body generated by Postman is just |
@kholmukhamedovme @reinouts Can you try out the latest version of Postman Canary (https://getpostman.com/canary), and see if that fixes this? We've rolled out a bunch of improvements around the OpenAPI import flow. |
@abhijitkane yes. I tried and here what we've got: It generates invalid JSON :( |
@abhijitkane Unfortunately the behavior is still the same. The generated request body is whatever is in the body |
@reinouts This seems to be a different issue - the JSON request body from the parameters property isn't handled. Can you file a new issue on https://github.com/postmanlabs/openapi-to-postman/issues, with a complete spec that's causing this? |
Thank you very much! This issue has been fixed in the latest v7.1.1-canary08. |
@kholmukhamedovme This is fixed in prod as well. |
Still broken for all kinds of multiple examples: https://swagger.io/docs/specification/adding-examples/ |
@ambition-consulting Issue is fixed but not working for example that you gave due to a different issue, I have created issue that is happening here. We will add any progress on the same over that thread. |
Okay, thank you. I'm looking forward to using the same data for testing and
Swagger execution. :-)
Vishal Shingala <[email protected]> schrieb am Di., 2. März 2021,
12:33:
… @ambition-consulting <https://github.com/ambition-consulting> Issue is
fixed but not working for example that you gave due to a different issue, I
have created issue that is happening here
<postmanlabs/openapi-to-postman#338>. We will
add any progress on the same over that thread.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6538 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABAF3XSKQJPTYB6YONAECZ3TBTEJ7ANCNFSM4HNVB7MA>
.
|
This doesn't work for me either. Is it even possible to get an example from an API spec into in a collection when you create the collection from the spec? I have tried many different ways of doing it: including it as a reference, including it inline. Nothing seems to work. |
@mryhmln To use examples from your API definition in collection, you need to provide certain options while generating the collection or importing definition. You can select options via |
Describe the bug
Examples are imported incorrectly from OpenAPI definition and the bug also appears while generating collection in APIs in Postman.
To Reproduce
Steps to reproduce the behavior:'
Expected behavior
To be able to receive the example response as defined for the collection.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context-
Removed postfix
/value
from OpenAPI definition described in the example, no result. Using/value
at the end of the reference link was the only way to get example visible in rendered HTML of Swagger UI`.App information (please complete the following information):
The text was updated successfully, but these errors were encountered: