Skip to content

Accept Headers on Examples not Inheriting Request when Generating from API Definition #11835

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

Closed
1 task done
fmiqbal opened this issue Mar 20, 2023 · 2 comments
Closed
1 task done

Comments

@fmiqbal
Copy link

fmiqbal commented Mar 20, 2023

Is there an existing issue for this?

  • I have searched the tracker for existing similar issues and I know that duplicates will be closed

Describe the Issue

When I generate the collection from API Definition, the request correctly guessed the Accept Header based on response (I suppose ?), but the examples that bound to that request doesn't have the correct (Accept) Header, so when using "Try" button, it fails, because the request need the headers.

Steps To Reproduce

  1. Import or create new API from OpenAPI 3.0 that have examples, I use this
{
    "openapi": "3.0.2",
    "info": {
        "title": "svc-activity",
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "http:\/\/localhost\/svc\/activity"
        }
    ],
    "paths": {
        "\/api\/log": {
            "post": {
                "summary": "Store",
                "description": "Create new log item",
                "responses": {
                    "201": {
                        "description": "201 Created",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "success": {
                                            "type": "boolean",
                                            "example": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "422 Validation Errors",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "$ref": "#\/components\/schemas\/response-validation-errors"
                                }
                            }
                        }
                    }
                }
            }
        },
        "\/api\/logs\/{log}": {
            "get": {
                "summary": "Show",
                "description": "Show one log by id",
                "parameters": [
                    {
                        "name": "log",
                        "in": "path",
                        "description": "Log ID",
                        "required": true,
                        "schema": {
                            "format": "int64",
                            "type": "integer",
                            "minimum": 0
                        },
                        "example": 1
                    }
                ],
                "responses": {
                    "200": {
                        "description": "200 OK",
                        "content": {
                            "application\/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "id",
                                        "metadata",
                                        "timestamp",
                                        "actor",
                                        "action",
                                        "namespace"
                                    ],
                                    "properties": {
                                        "id": {
                                            "description": "UUID of the object",
                                            "format": "int64",
                                            "type": "integer",
                                            "example": 12
                                        },
                                        "namespace": {
                                            "description": "Where this actions took, preferably service name. Must be exists before",
                                            "type": "string",
                                            "example": "some-project"
                                        },
                                        "action": {
                                            "description": "What is the action",
                                            "type": "string",
                                            "example": "create_user"
                                        },
                                        "actor": {
                                            "description": "Who took the action, Subject, string, can be id, email, username",
                                            "type": "string",
                                            "example": "email@email.com"
                                        },
                                        "timestamp": {
                                            "format": "date-time",
                                            "type": "string"
                                        },
                                        "metadata": {
                                            "type": "object",
                                            "nullable": true
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "404 Not Found"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "response-validation-errors": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string",
                        "example": "The given data was invalid."
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "example": {
                            "field": [
                                "Something is wrong with this field!"
                            ]
                        }
                    }
                }
            }
        }
    }
}
  1. Use "Generate from definition" function
    image
    image

  2. Observe that the accept headers on examples doesn't match with its request
    image
    image
    image

Screenshots or Videos

No response

Operating System

Linux

Postman Version

10.12.4

Postman Platform

Postman App

User Account Type

Signed In User

Additional Context?

No response

@VShingala
Copy link
Member

@fmiqbal Thanks for reporting the issue! We were able to reproduce the issue you mentioned and we're working on a fix for this. We'll update here once we have the fix available.

@fmiqbal
Copy link
Author

fmiqbal commented May 13, 2023

I observe that in v10.13.5 , the header is correctly passed to the try page. I suppose this issue is considered to be fixed

@fmiqbal fmiqbal closed this as completed May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants