openapi-transformer-toolkit
openapi-transformer-toolkit copied to clipboard
feat: generate schema from paths OpenAPI prop
-
oas2json
looks fine butoas2ts
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
orpaths
- tests will fail as output path has changed and types references/imports are not always correct.
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
Hi @faizplus! A few questions:
- Is this PR trying to provide supports to other props than
components.schemas
for all 3 methodsoas2json
,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!
Hi @faizplus! A few questions:
- Is this PR trying to provide supports to other props than
components.schemas
for all 3 methodsoas2json
,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
oroas2ts
) 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.