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

feat: support typespec as an input format #158

Merged
merged 8 commits into from
Apr 27, 2024
Merged

Conversation

mnahkies
Copy link
Owner

adds https://typespec.io/ as a supported input format, using it's typespec -> openapi3 conversion package.

  • new optional cli option --input-type=[openapi3|typespec], defaulting to openapi3
  • converts provided typespec files to openapi3 on the fly, and then proceeds with generate as normal
  • it could probably be better, I haven't figured out what to do with multiple versions / services in a single spec
  • requires that you manually install the relevant optional peerDependencies, eg:
yarn add "@typespec/compiler" "@typespec/http" "@typespec/openapi" "@typespec/openapi3" "@typespec/versioning"

also finally got sick of xargs requiring a 255 exit code to halt on failure, and switched the integration test generation scripts over to node, which also prefixes the output to make it easier to follow.

resolves #148

@@ -24,8 +24,18 @@
"test": "jest"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "^0.41.1",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just required by the integration tests, hence not included in peerDependencies

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split from packages/openapi-code-generator/src/core/file-loader.ts - not actually changed, aside from using json5 for parsing json input

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split from packages/openapi-code-generator/src/core/file-loader.ts - not actually changed

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the meat of the implementation

@mnahkies mnahkies marked this pull request as ready for review April 27, 2024 16:08
@mnahkies mnahkies merged commit b1cdbf4 into main Apr 27, 2024
1 check passed
@mnahkies mnahkies deleted the mn/148/typespec-support branch April 27, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support typespec as an input format
1 participant