How to modify existing interfaces #1329
-
I am writing a system that can be used to query JSON. It will be used in a domain specific language that I am also writing. The syntax is similar to TaffyDB query syntax, and a query essentially specifies a path to a JSON property and a criteria for a value that must be satisfied. The first step in validating the query syntax is to determine if the specified property path exists or not. In order to do this, I will use a schema that is loaded from an OpenAPI specification. Since the spec is OpenAPI compiant, the structure of the schema object is expected to match that of a Here is a synopsis of the steps that I'm trying to accomplish:
Can anyone provide input on how I could accomplish this? I'd like to not have to hand code the OpenAPI schema types and interfaces, but would rather use the ones that are already provided here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yeah this is difficult in general to do! While I think this wasn’t originally clear when I started the project, it’s become more apparent with time that This is in stark opposition to the runtime analysis approach to Swagger Codegen and other libraries like I say that because I see both static analysis and runtime analysis components to your question. This library and its tools can only help out with the former. For the static analysis part, I’d take a look at the openapi-typescript-helpers package in this repo. Though there’s not documentation, you can see how it’s used in openapi-fetch, such as For the runtime analysis part, there’s no part of this tool that will actually perform the runtime checking. That will either be on your part, or you could look into a generic tool like zod that’s a general-purpose runtime validator. But keep in mind that Zod is probably not the best thing to do either in a browser or a production server, and is probably best suited for local testing or as part of a build step. |
Beta Was this translation helpful? Give feedback.
Thanks @drwpow. I ended up bringing in a different library that provided more interfaces and classes and fewer type declarations. While I didn't end up modifying the prototype, I did manage to get an implementation up and running.