joolfe / postman-to-openapi

🛸 Convert postman collection to OpenAPI
MIT License
577 stars 99 forks source link

Generating Schemas from examples #237

Open Kinjalrk2k opened 1 year ago

Kinjalrk2k commented 1 year ago

Few notable points:

Referencing important issues:

Kinjalrk2k commented 1 year ago

I was looking into the requestBody and found that the data returned is:

{
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "example": {
            "id": "100",
            "createdAt": "2021-06-04T15:50:38.568Z",
            "name": "Carol",
            "avatar": "https://cdn.fakercloud.com/avatars/nelsonjoyce_128.jpg"
          }
        }
      }
    }
  }
}

Shouldn't the requestBody be:

{
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "type": "object"
        },
        "example": {
          "id": "100",
          "createdAt": "2021-06-04T15:50:38.568Z",
          "name": "Carol",
          "avatar": "https://cdn.fakercloud.com/avatars/nelsonjoyce_128.jpg"
        }
      }
    }
  }
}

What I want to point out is wont the schema and example fields be on the same level? Reference: https://swagger.io/docs/specification/describing-request-body/

Please guide me to the right direction if I'm wrong!

Mehrdad-Dadkhah commented 1 year ago

please check and merge this PR @joolfe

joolfe commented 1 year ago

@Kinjalrk2k I need some time to review but I'm taking it into consideration, thanks so much for the PR.

mindrunner commented 1 year ago

This repo lacks an important feature and the MR at least enables basic support for that. However, the repo from @Kinjalrk2k seems outdated and not maintained as well as fails npm audit.

I would really appreciate a solution here and I think other would do too. Maybe the perfection in #246 can be a long term goal, but with intermediate steps (e.g. this MR)?

Thanks for everyones effort. This generators saves a lot of work!!!

doggy8088 commented 7 months ago

@joolfe Are you able to review this PR?

soerenuhrbach commented 6 months ago

I created a package that provides a function to create the missing schema types for request bodies and responses based on the examples. I will deprecate the package if the PR is merged but this repository seems pretty dead.

https://github.com/soerenuhrbach/openapi-schema-types-from-examples#use-with-postman-to-openapi