-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: addition of a getRequestBody accessor #580
Conversation
4e8e4bf
to
ab86b89
Compare
describe('#getResponseByStatusCode()', () => { | ||
it('should return false if the status code doesnt exist', () => { | ||
const operation = Oas.init(petstore).operation('/pet/findByStatus', 'get'); | ||
expect(operation.getResponseByStatusCode(202)).toBe(false); | ||
}); | ||
|
||
it('should return the response', () => { | ||
const operation = Oas.init(petstore).operation('/pet/findByStatus', 'get'); | ||
it('should return the response', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to rework this test a bit because the dereferencing library we use does parameter reassigning so if one test dereferences the petstore spec then tests that use that spec after it will have a dereferenced spec.
} | ||
|
||
const requestBody = this.schema.requestBody; | ||
if (RMOAS.isRef(requestBody) || !(mediaType in requestBody.content)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return false if it's a ref? It's probably worth leaving those details as a comment here. I also don't see any tests for when the req body is a ref.
🧰 Changes
Adds a new
getRequestBody
accessor on theOperation
object that pulls back a request body Media Type Object for any specific media type that's present on the operation.This isn't going to be used anywhere just yet but when we refactor/rewrite the
getSchema()
library here it can be used there.🧬 QA & Testing
See tests.