zerocode
zerocode copied to clipboard
Support OpenAPI Specification
It would be nice if we can support Open API Spec in terms of generating zero code tests directly from api spec.
Add more details what all can be supported in the library in context of open spec.
Open Spec reference https://github.com/OAI/OpenAPI-Specification
Requirement from @warademilind :
--- write here ---
Requirement from @SuyogSSS :
--- write here ---
Nice one.
@BeTheCodeWithYou may I work on this issue?
@pgmpofu thanks for interest in contributing. Yes please you could very well pickup this item. Would be great if we can discuss on the approach you are looking to implement.
idea is to develop zerocode plugin/utility and use it in below scenario
AC
GIVEN a REST API contract defined in the Open Spec WHEN zerocdoe utility is executed THEN it generates ZeroCode test JSON steps.
example:- uber.json in Open API Spec ( this is just a sample JSON. you could create a simple json based on open spec and then proceed ) https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/uber.json
@authorjapps add more points to AC if you think of.
Can I work on this issue ?
Please assign it to me
@respondsid , Yes will do. Thanks 👍 Can you please fork the repo ? Basically we collaborate this way... (a bit of discipline for all our benefits)
- The new contributors fork the Zerocode repo to their own repo and make changes there.
Just press fork button
- Once the impl/fix is done, they raise a PR
- Once PR is approved, we add them to the contributors list.
- And display their name in our Author/Collaborator page 👍
@pgmpofu, it seems like you are bit occupied in your current work, which is fine. But you can certainly help us in reviewing the PR. We will inform you when the PR is ready.
@respondsid , Basically our approach could be in this way.
Once we figure out how to parse the open-api/swagger
spec-json, we have to fit the
url, method, request, response to the below two classes
org.jsmart.zerocode.core.domain.Step
org.jsmart.zerocode.core.domain.ScenarioSpec
You can use the constructor of the above classes to generate the JSON steps.
Then just
mapper.writeValueAsString(step); //<--- only a step and/or mapper.writeValueAsString(scenarioSpec); //<--- Scenario with steps
Initially we could assume that
- Open API spec json is available to us somewhere in the
src/test/resources
or- Somewhere in the
internet/gitrepo
(we can try this in the next version in a separate ticket) - A maven Plugin (we will try in next version in separate ticket)
- Somewhere in the
- Then we will have a util class e.g.
OpenSpecApiToZeroCodeStepGenerator.java
with method e.g.List<String) generate(String openSpecJsonPath)
- Each item in the list will be a scenario test-case having one or more steps(depending on the OpenApi spec)
- This
generate
method will also write totarget/generated-tests
- The number of items in the List<String> will be generated as
zerocode .json test-case
file
- The number of items in the List<String> will be generated as
- For time being we can name the files as
<resourceName_crud_test.json>
Oh thanks for the pointer i was planni g on using mustache temolates but this ine sounda even better
On Wed, Apr 3, 2019, 3:59 PM authorjapps [email protected] wrote:
@respondsid https://github.com/respondsid , Basically our approach could be in this way. Once we figure out how to parse the open-api/swagger spec-json, we have to fit the url, method, request, response to the below two classes
org.jsmart.zerocode.core.domain.Step
org.jsmart.zerocode.core.domain.ScenarioSpec
You can use the constructor of the above classes to generate the JSON steps.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/authorjapps/zerocode/issues/195#issuecomment-479636708, or mute the thread https://github.com/notifications/unsubscribe-auth/AQfIZwX8oJgmu3Zgj9us_HD0B9fxV53Eks5vdQgGgaJpZM4aR0CI .
I was able to parse the spec
On Wed, Apr 3, 2019, 3:59 PM authorjapps [email protected] wrote:
@respondsid https://github.com/respondsid , Basically our approach could be in this way. Once we figure out how to parse the open-api/swagger spec-json, we have to fit the url, method, request, response to the below two classes
org.jsmart.zerocode.core.domain.Step
org.jsmart.zerocode.core.domain.ScenarioSpec
You can use the constructor of the above classes to generate the JSON steps.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/authorjapps/zerocode/issues/195#issuecomment-479636708, or mute the thread https://github.com/notifications/unsubscribe-auth/AQfIZwX8oJgmu3Zgj9us_HD0B9fxV53Eks5vdQgGgaJpZM4aR0CI .
When we have a working version(which we are close to it already), then we will try to refine it a bit to take the following into account (sometimes later as we proceed). I am just putting them here before it goes from our minds :-)
- Initial version - Clone the swagger-zerocode-gen repo and run
- Later - Generate a uber jar(fat jar) and provide command line option
java -jar swagger-zerocode-gen.jar --o all
java -jar swagger-zerocode-gen.jar --o requiredFieldsOnly
java -jar swagger-zerocode-gen.jar --o randomizeRequestFields
java -jar swagger-zerocode-gen.jar --o queryParamSection
etc... We will add more options here as we proceed
- One additional step with the required fields only, with step name as
path_required_fields
One step with all the fields(as usual currently working)
- To randomize a request field we can generate this way
"name": "${RANDOM.STRING:10}",
"name": "Name ${RANDOM.STRING:10}",
"id": "person_id_${RANDOM.NUMBER}",
@respondsid , Could you please
Join the collaborators mailing list https://groups.google.com/forum/#!members/zerocode-automation
Join Gitter room https://gitter.im/zerocode-testing/help-and-usage
Cheers 👍
Hi Team, i would like to work on this issue. Can any one guide me, how to start
hi all - forking the repo, hopefully will be back here sooner than later with a PR :)
@lukecolpo , thanks for your interest 🙏 Can we have a brief chat about the requirements, ACs etc. That might give you a better understanding of the output that will be useful to the end users(developer as well as testers)!
Are you already in Slack ?
@authorjapps sure!!! i've been getting up to speed with the code base as well as the new spec, so i think that'd be a great idea. I'll join the slack
@lukecolpo any positive update on this issue or Should I ask @authorjapps to assign this issue to me ?
@authorjapps , @santhoshTpixler , @respondsid Is this issue still open. I am using Zerocode for long time, but it will be good if integration with OpenApi will be possible. As it will be make automation faster and without many changes. As OpenApi is well maintained and if we can use it in Zerocode then it's great.
I was looking for something similar and stumbled on to this. @authorjapps Any positive updates?
Hi @SuyogSSS , @warademilind , Looks like you bath have different requirements here than the original ticket. Let me know if my assumption is wrong.
Please provide your requirements what exactly you want to do. I will try to help.
I have created space specific to you both(see here(click) ). Please put the details. I will create separate ticket if needed, so not to worry in terms of matching the original ticket.
The original ticket demands very large implementation. Hence this ticket is kept opened and unable to get proper light to see the solution yet.
@warademilind : Put your requirement step by step here what you want to achieve or test.
@SuyogSSS : Put your requirement step by step here what you want to achieve or test.
@nirmalchandra , please find below example of OpenAPI specification.
https://petstore.swagger.io/
If we can integrate this with Zerocode it will be very useful.