Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Validate response against openapi schema #591

Closed
timo-klarshift opened this issue May 17, 2024 · 1 comment
Closed

Validate response against openapi schema #591

timo-klarshift opened this issue May 17, 2024 · 1 comment
Labels
feature 🚀 New feature or request

Comments

@timo-klarshift
Copy link

Description

Hey, first of all thanks for the great library. I am so happy to finally drop openapi-generator :)

I have the use-case that I am developing an SDK/client against a legacy API. During tests we find cases where the provided schema does not match the actual backend responses. What I would like to have is schema validation when a response is returned. I do of course have the openapi schema available, but my attempt using Interceptors is not successful because when I receive the response I have no access to the request, therefore I do not know what method was called on the url which means I cannot match the response to an operation without ambiguity.

I see it would be possible by replacing the whole request.ts file which is possible via config. But actually I would only need to alter the sendRequest method for this purpose. Here I do have the RequestInit and could process the returned Response from fetch. Then get my schema and validate whether the returned response for said operation is valid against the provided schema. If not I would want to log a warning.

Another way to solve it would be not on request implementation layer (fetch in this case) but on library layer. We could add a similar interceptor concept but extend the Response interface so it would contain a reference to RequestInit. Also adding some meta-data could be helpful, for example operationId from the schema.

I hope this use-case is clear, maybe there is already some way to implement this which I cannot see yet.

@timo-klarshift timo-klarshift added the feature 🚀 New feature or request label May 17, 2024
@timo-klarshift timo-klarshift changed the title Response schema validation against returned responses Validate response against openapi schema May 17, 2024
@mrlubos
Copy link
Contributor

mrlubos commented May 17, 2024

Welcome @timo-klarshift! 🚀 pretty sure I've heard this request a few times already, it's going to get addressed, but it will take a while as there's a lot to build!

@hey-api hey-api locked and limited conversation to collaborators Jun 24, 2024
@mrlubos mrlubos converted this issue into discussion #719 Jun 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
feature 🚀 New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants