Skip to content
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

Importing OData requests with key segments through OpenAPI document results in unusable Path Variables #101

Open
twaalewijn opened this issue Jul 22, 2019 · 0 comments
Labels
bug

Comments

@twaalewijn
Copy link

@twaalewijn twaalewijn commented Jul 22, 2019

Describe the bug
I have an ASP.NET Core service that uses OData and exposes an OpenAPI endpoint with the help of this library.

The output of this endpoint is an OpenAPI document serialized to JSON.

Using a theoretical model of two entities:

  • project (with key project_id)
  • subproject (with composite key project_id, subproject_id)

The document would contain a set of OData request paths to select a project or subproject by key:

  • /project({project_id})
  • /subproject(project_id={project_id},subproject_id={subproject_id})

When this document is imported into Postman as a collection it changes the key variables in these requests to Path Variables:

  • {{baseUrl}}/project(:project_id)
  • {{baseUrl}}/subproject(project_id=:project_id,subproject_id=:subproject_id)

When sending these requests, any value entered for the Path Variable is not being replaced in the final URL.

To Reproduce

  1. Import the following snippet as a collection:
{
  "openapi": "3.0.1",
  "info": {
    "title": "Bug example",
    "description": "Bug example for path variable as OData key.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://localhost/service"
    }
  ],
  "paths": {
    "/project({project_id})": {
      "get": {
        "tags": [
          "project"
        ],
        "summary": "Get entity from project by key",
        "operationId": "project.GetProject",
        "parameters": [
          {
            "name": "project_id",
            "in": "path",
            "description": "key: project_id",
            "required": true,
            "schema": {
              "maximum": 2147483647,
              "minimum": -2147483648,
              "type": "integer",
              "format": "int32",
              "nullable": true
            }
          }
        ],
        "x-ms-docs-operation-type": "operation"
      }
    },
    "/subproject(project_id={project_id},subproject_id={subproject_id})": {
      "get": {
        "tags": [
          "subproject"
        ],
        "summary": "Get entity from subproject by key",
        "operationId": "subproject.GetSubproject",
        "parameters": [
          {
            "name": "project_id",
            "in": "path",
            "description": "key: project_id",
            "required": true,
            "schema": {
              "maximum": 2147483647,
              "minimum": -2147483648,
              "type": "integer",
              "format": "int32",
              "nullable": true
            }
          },
          {
            "name": "subproject_id",
            "in": "path",
            "description": "key: subproject_id",
            "required": true,
            "schema": {
              "maximum": 2147483647,
              "minimum": -2147483648,
              "type": "integer",
              "format": "int32",
              "nullable": true
            }
          }
        ],
        "x-ms-docs-operation-type": "operation"
      }
    }
  }
}
  1. Open either one of the added GET requests.
  2. Change the value of the Path Variables for the request.
  3. Open the Postman Console with Alt+Ctrl+C
  4. Send the request.
  5. Observe in the console that the variables have not been replaced.

Expected behavior
Either the variables in the URL should get replaced or, if Path Variables are not meant to be used in this case, convert the key variables in the document to provide another way to set the variables.

For example, instead of changing them to Path Variables, they could be converted to regular {{variables}} with a generated script to set them through the Pre-request Script tab similar to what is done for {{baseUrl}}.

Screenshots
postman odata key variable bug

App information (please complete the following information):

  • App Type: Postman for Windows
  • Postman Version: 7.2.2
  • OS: Windows 10 (win32 10.0.14393 / x64)
@abhijitkane abhijitkane transferred this issue from postmanlabs/postman-app-support Jul 24, 2019
@umeshp7 umeshp7 added the bug label Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.