Skip to content
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

Support OpenAPI Specification #195

Open
3 tasks done
BeTheCodeWithYou opened this issue Jan 24, 2019 · 23 comments · May be fixed by #695
Open
3 tasks done

Support OpenAPI Specification #195

BeTheCodeWithYou opened this issue Jan 24, 2019 · 23 comments · May be fixed by #695

Comments

@BeTheCodeWithYou
Copy link
Collaborator

BeTheCodeWithYou commented Jan 24, 2019

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

Edited (2024-10-27):
Create a Proof of Concept:

  • AC1: Generate the required Zerocode scenarios/steps to cover all paths, operations and schemas of the Swagger Petstore.
  • AC2: Use zerocode tokens (e.g. ${RANDOM.STRING:10}) as the generated random values.
  • AC3: Implement in a separate module (e.g. zerocode-openapi).

Tasks:

  • Generate the scenarios/steps covering the most common features in the petstore spec without errors.
  • Complete the generator to support all petstore spec features.
  • E2E test against the real API and fix the issues that will appear.
@santhoshTpixler
Copy link
Collaborator

Nice one.

@pgmpofu
Copy link

pgmpofu commented Mar 2, 2019

@BeTheCodeWithYou may I work on this issue?

@BeTheCodeWithYou
Copy link
Collaborator Author

BeTheCodeWithYou commented Mar 2, 2019

@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.

@respondsid
Copy link
Collaborator

Can I work on this issue ?

@respondsid
Copy link
Collaborator

Please assign it to me

@authorjapps
Copy link
Owner

@respondsid , Yes will do. Thanks 👍
Can you please fork the repo ?
Basically we collaborate this way... (a bit of discipline for all our benefits)

  1. The new contributors fork the Zerocode repo to their own repo and make changes there.

    Just press fork button

  2. Once the impl/fix is done, they raise a PR
  3. Once PR is approved, we add them to the contributors list.
  4. 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.

@authorjapps
Copy link
Owner

authorjapps commented Apr 3, 2019

@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)
  • 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 to target/generated-tests
    • The number of items in the List will be generated as zerocode .json test-case file
  • For time being we can name the files as <resourceName_crud_test.json>

@respondsid
Copy link
Collaborator

respondsid commented Apr 3, 2019 via email

@respondsid
Copy link
Collaborator

respondsid commented Apr 3, 2019 via email

@authorjapps
Copy link
Owner

authorjapps commented Apr 7, 2019

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}",

@authorjapps
Copy link
Owner

@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 👍

@cns45
Copy link

cns45 commented Aug 24, 2019

Hi Team, i would like to work on this issue. Can any one guide me, how to start

@lukecolpo
Copy link

hi all - forking the repo, hopefully will be back here sooner than later with a PR :)

@authorjapps
Copy link
Owner

@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 ?

@lukecolpo
Copy link

@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

@dhavalshah007
Copy link

@lukecolpo any positive update on this issue or Should I ask @authorjapps to assign this issue to me ?

@warademilind
Copy link

warademilind commented Aug 11, 2021

@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.

@SuyogSSS
Copy link

I was looking for something similar and stumbled on to this.
@authorjapps Any positive updates?

@nirmalchandra
Copy link
Collaborator

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.

@warademilind
Copy link

@nirmalchandra , please find below example of OpenAPI specification.

https://petstore.swagger.io/

If we can integrate this with Zerocode it will be very useful.

@gfiedler
Copy link

How about adding a new generator for zerocode configuration files in the openapi-generator project?

https://github.com/OpenAPITools/openapi-generator

@javiertuya
Copy link
Collaborator

I agree with everyone that this is a very nice feature. There have been many volunteers to work on it and many interesting suggestions. However, this issue has been stalled for a long time.

One possible way to reactivate this feature could be to create a Proof of Concept as starting point and then evaluate, discuss and refine it.

I have previously worked on parsing and manipulating OpenAPI specs, and with the swagger petstore, so I could have this POC ready in a short time frame. Borrowing some previous suggestions, this could be:

  • AC1: Generate the required Zerocode scenarios/steps to cover all paths, operations and schemas of the Swagger Petstore.
  • AC2: Use zerocode tokens (e.g. ${RANDOM.STRING:10}) as the generated random values.
  • AC3: Implement in a separate module (e.g. zerocode-openapi).

@authorjapps What are your thoughts on this?

@authorjapps
Copy link
Owner

authorjapps commented Oct 27, 2024

I agree with everyone that this is a very nice feature. There have been many volunteers to work on it and many interesting suggestions. However, this issue has been stalled for a long time.

One possible way to reactivate this feature could be to create a Proof of Concept as starting point and then evaluate, discuss and refine it.

I have previously worked on parsing and manipulating OpenAPI specs, and with the swagger petstore, so I could have this POC ready in a short time frame. Borrowing some previous suggestions, this could be:

  • AC1: Generate the required Zerocode scenarios/steps to cover all paths, operations and schemas of the Swagger Petstore.
  • AC2: Use zerocode tokens (e.g. ${RANDOM.STRING:10}) as the generated random values.
  • AC3: Implement in a separate module (e.g. zerocode-openapi).

@authorjapps What are your thoughts on this?

@javiertuya , Yes. Sounds very right.
To start with a POC will definitely help. 👍

My suggestions would be (for everyone involved in this):
=> Do not get carried away or overwhelmed by the existing PRs attached to this issue(you can totally ignore the existing PRs if it doesn't make sense to you, as the lib and the openspi ecosystem might have evolved or changed by now, opposed to when this ticket was raised). Use the ACs for the solution, for everyone to be at the same page
=> AC1 to AC3 : Capture these ACs into the issue-description (currently missing)
=> AC3: Sounds good. First check via the PoC, if all things hangs together well. But idea is good.

@javiertuya javiertuya self-assigned this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.