Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Conversation

Kinjalrk2k
Copy link

@Kinjalrk2k Kinjalrk2k commented Nov 1, 2022

Few notable points:

  • All the examples are inspected and then a common schema is generated
  • This schema is then automatically injected with the already generated response content.
  • Only application/json responses will have a schema.
  • Updated test cases to support response schemas

Referencing important issues:

@Kinjalrk2k
Copy link
Author

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
Copy link

please check and merge this PR @joolfe

@joolfe
Copy link
Owner

joolfe commented Nov 6, 2022

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

@joolfe joolfe mentioned this pull request Nov 26, 2022
7 tasks
@mindrunner
Copy link

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
Copy link

@joolfe Are you able to review this PR?

@soerenuhrbach
Copy link

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

@joolfe
Copy link
Owner

joolfe commented Dec 27, 2024

close because of archive, read the README for more info about that decision.

@joolfe joolfe closed this Dec 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants