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
ScanAPI spec from an OpenAPI specification #206
ScanAPI spec from an OpenAPI specification #206
Conversation
I think the only thing missing is to write the tests for this. I didn't do it because i'm not familiar with how you're writing them. |
Hi @abreumatheus thanks for the PR! About the tests, you can create a file called Usually, what I do, is to create classes to give some context about the tests, something inspired in BDD: class TestFileName: # example: TestRegistration
class TestFunctionName: # example TestRegisterAccount
class TestContext: # example TestWhenDataIsIncomplete
def test_expect_behaviour(self): # example test_should_return_422
pass but don't worry to use it if you don't feel comfortable. |
@camilamaia Thank you for the explanation, makes a lot more sense now hahaha. I use a different aproach at work with unittest. Will try here :) |
@abreumatheus no problem! If you feel stuck or struggling too much, please let me know! We can do a pair or something like this. |
Hey, @camilamaia. Test:
Error:
Ps: I pushed the failing test, if you wanna try it yourself. |
@camilamaia Any news on this? Sorry to bother, really wanna finish this feature to see it working live 😁. |
Hi @abreumatheus ! I was super busy in the last week, sorry. But I will check it in the beginning of this week |
@abreumatheus I got the problem! The test was trying to get the group instead of the module when mocking, because they have the same name "main". What I did and worked was to change the name of the file from I also changed the relative paths like this, because they did not work on my machine. I invited you to the organization, I don't know if you saw it. Cause if you are in the org, you don't need to use a forked project and can grab from the origin branch i've just pushed to. |
openapi_to_yaml('../data/openapi.json') | ||
|
||
assert os.path.exists('./api.yaml') | ||
|
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.
Can we have an assert here for the expected result? We could create a file in the data folder with the result:
api:
endpoints:
- name: Uber API
path: https://api.uber.com/v1
requests:
- name: Product Types
path: /products
method: get
- name: Price Estimates
path: /estimates/price
method: get
- name: Time Estimates
path: /estimates/time
method: get
- name: User Profile
path: /me
method: get
- name: User Activity
path: /history
method: get
and assert the content matches. What do you think?
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.
@abreumatheus I was noticing that the query params, for example, are not in the expected result. Is this intentional? Does it work for headers, body and others http methods than get
too? If not, we can create more issues for them, no problem, I just want to understand the context here. Thanks!!
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.
@camilamaia Will assert the expected result. I really forgot about the query/path parameters and headers hahaha. I was analyzing it here and i have to work on a couple more things too, like ofering support for the new 3.0 version of OpenAPI that, among some differences, can also come on YAML format now. I was thinking about closing this PR, since it will require a lot of new things and open another one when it's all trully ready and beautiful 😄 . What do you think?
Edit: It seems i don't have permission to push branches to the repository, i'm also working on the json render, so i will push to my fork.
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.
@abreumatheus I added you to the team which can push stuff, sorry! I needed you to accept the invite first. But it should be all set now 👌 Please, let me know if you keep having problems.
What you can do is to work in a branch as a draft. Because this is getting in a good shape. Actually, the way you prefer works for me!
Good catch about the OpenAPI 3.0 👀 I was forgetting it too!
@abreumatheus Did the trick of changing the |
Yes! It did! |
Refers to: [#12 ]
Added
Changed
scanapi
toscanapi run
;