Skip to content

feat: support typespec as an input format#158

Merged
mnahkies merged 8 commits intomainfrom
mn/148/typespec-support
Apr 27, 2024
Merged

feat: support typespec as an input format#158
mnahkies merged 8 commits intomainfrom
mn/148/typespec-support

Conversation

@mnahkies
Copy link
Copy Markdown
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

"test": "jest"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "^0.41.1",
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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