Fork me on GitHub
#pathom
<
2024-02-16
>
sheluchin18:02:02

Is there any way to automatically create resolvers from an OpenAPI schema?

wilkerlucio18:02:10

maybe its possible, I never tried for real

sheluchin18:02:30

OAI schemas and Pathom seem like a good match. I'm surprised there isn't really any discussion on the subject here. In theory, the mapping of an OAI endpoint to a resolver should be straight forward.

wilkerlucio19:02:02

depends on how good their schema can capture things, I looked at it once, and one thing that might be tricky is to figure the semantic mapping for the input arguments for the endpoints

wilkerlucio19:02:06

I remember seeing things where the input is declared as a name with a type, how you name them (whats the namespace?)? how you relate them to outputs from other endpoints?

wilkerlucio19:02:32

this I think is the tricky part, I think there might be a solution (even if its not fully automatic). its an interesting thing to explore for sure 🙂

sheluchin19:02:28

> whats the namespace? This part is tricky since there are no namespaces in JSON, but maybe namespacing in this case can just be ignored or use a constant namespace similar to ::p.gql/namespace "swapi"? > how you relate them to outputs from other endpoints? This can obviously differ depending on the quality of the spec, but presuming its perfect, we should be able to refer to the top-level definitions key in the spec. Like the canonical https://petstore.swagger.io/v2/swagger.json includes a definition for Pet and then refers to it using a ref like "#/definitions/Pet" where that type is returned. Somewhere along the way it might require manually creating a renames-map or something of the sort.