openapi-transformer-toolkit icon indicating copy to clipboard operation
openapi-transformer-toolkit copied to clipboard

feat: generate schema from paths OpenAPI prop

Open faizplus opened this issue 9 months ago • 3 comments

  • oas2json looks fine but oas2ts is not creating correct types references/imports
  • introduces breaking changes as generated schema/types files now reside inside their node folder e.g. components.schemas or paths
  • tests will fail as output path has changed and types references/imports are not always correct.

faizplus avatar Apr 30 '24 14:04 faizplus

No linked issues found. Please add the corresponding issues in the pull request description.
Use GitHub automation to close the issue when a PR is merged

github-actions[bot] avatar Apr 30 '24 14:04 github-actions[bot]

Hi @faizplus! A few questions:

  • Is this PR trying to provide supports to other props than components.schemas for all 3 methods oas2json, oas2ts, oas2tson?
  • How would it work? Would openapi-transformer-toolkit generate schemas for any prop found in the OpenAPI definition or just a specific subset of it?
  • Could you briefly explain the conversion flow this PR tries to implement?

I'd personally suggest to try and implement such feature method by method (maybe starting from oas2json or oas2ts) and make sure that we find a usable UX/API to start with.

Thanks!

toomuchdesign avatar Apr 30 '24 15:04 toomuchdesign

Hi @faizplus! A few questions:

  • Is this PR trying to provide supports to other props than components.schemas for all 3 methods oas2json, oas2ts, oas2tson?
  • How would it work? Would openapi-transformer-toolkit generate schemas for any prop found in the OpenAPI definition or just a specific subset of it?
  • Could you briefly explain the conversion flow this PR tries to implement?

I'd personally suggest to try and implement such feature method by method (maybe starting from oas2json or oas2ts) and make sure that we find a usable UX/API to start with.

Thanks!

Hey @toomuchdesign, I am currently trying to add support for paths and you can see the output of oas2json in example/output/json and output of oas2ts in example/output/types

With this PR, i have added one more option to oas2json and oas2ts as -p where you can pass other prop names like paths from open api yml file. Then raw yml content is parsed const parsedOpenAPIContent = YAML.parse(openAPIContent) then schema is generated

const generatedSchema = fromSchema(parsedOpenAPIContent, {
   definitionKeywords
})

then I have created a function (convertOpenApiPathsToSchema) specific for paths which accepts generatedSchema.paths which generates separate schema file for each path in paths property from openapi yml.

faizplus avatar Apr 30 '24 16:04 faizplus