openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Allow to export spec object

Open alorle opened this issue 9 months ago • 6 comments

Description

It would be nice to be able to export the specification with which the code was generated as a variable. This could be done in either a new plugin or the schema plugin.

This would be useful for example for the fastify plugin, since the library used in the example for routing (fastify-openapi-glue) needs the specification for input/output validation.

I would be happy to create a PR if necessary.

alorle avatar Apr 30 '25 18:04 alorle

So you'd be persisting the spec in your generated output?

mrlubos avatar May 01 '25 07:05 mrlubos

That's right. The goal is to be able to have It at runtime, yes.

alorle avatar May 01 '25 07:05 alorle

Does it need to be fully resolved? Thinking about multi-spec scenarios

mrlubos avatar May 01 '25 08:05 mrlubos

I'm not sure I fully understand your point. As far as I know, @hey-api doesn't support multi-specs, right?

alorle avatar May 01 '25 08:05 alorle

Yeah but that doesn't matter. I want to understand the scope of the feature for future reference. If we'd need to support multiple specs, then we'd do that 🤠

mrlubos avatar May 01 '25 08:05 mrlubos

It makes sense 😅. In that case, if the system treats each spec separately, I would say that it would have to create a variable for each of the specs.

alorle avatar May 01 '25 08:05 alorle