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

Service Virtualization Feature enhancement #196

Merged
merged 59 commits into from
Sep 5, 2018
Merged

Service Virtualization Feature enhancement #196

merged 59 commits into from
Sep 5, 2018

Conversation

elans3
Copy link
Contributor

@elans3 elans3 commented Jun 1, 2018

I am one of the swagger/Open API user and would like to be a future contributor to the community. I had started developing a virtualized service idea and donate the code to Swagger community from the beginning.

How can we use codegen project into Service Virtualization, As it holds tremendous potential to help testers boost test automation and keep pace with Agile and DevOps demands. If Developer/Tester being pressured to test faster and/or earlier in each release cycle (e.g., “shift left”), Service Virtualization could help advance development team’s Continuous Testing and development efforts and lot more in the API Contract driven world"

I have been working on project and had a requirement to develop a virtualized service. I had customized swagger codegen to create a virtualized service generation for the any given REST Yaml contract with JSON support.

How to setup virtualized service for all your Rest contracts in less then 10 minutes...
Required Info:
https://github.com/elans3/openapi-generator/blob/master/modules/openapi-generator-virtualan/src/main/resources/java-config.json

Setup Instruction: (All steps are same used as Swagger codegen as reference)
https://virtualmockservice.blogspot.com/2018/04/hi-everyone-in-this-microservice-world.html

Please let me know if you need any additional details. I would be eager to help integrate with codegen project.
Thanks,
Elan

@jmini
Copy link
Member

jmini commented Jun 5, 2018

Sorry to ask stupid question, but how does this project is related to openapi-generator? I do not see where openapi-generator is used. What is the dependencies between the "Service Virtualization Feature" and "OpenAPI Generator"...

@wing328: maybe we could publish it as a new project inside the https://github.com/OpenAPITools organization?

@elans3 What do you think about this proposition? Can you give me more details?

@elans3
Copy link
Contributor Author

elans3 commented Jun 5, 2018

@jmini

Reason would be - Virtualized service had developed using the Open API Code generation project with openapi-generator-cli CLI tool.

Refer the codegen files that would generate as "Virtualized" service.

Automated API Testing.

  • Using cucumber setup the service Data in the Virtualized service to Setup data for the Resource-API Call would be tested
  • Run the API Calls and Validate the response.
  • Will be creating some testcases ASAP using Cucumber with this deliverable.
  • Certify the functional requirement in DEV Environment without Real Implemented services .
    and Etc..

- Maven plugin related changes
- Samples added
Build issue resolved - Tab space was removed..
@elans3
Copy link
Contributor Author

elans3 commented Aug 30, 2018

Virtualan had released under io.virtualan.virtualan-plugin with 1.0.0. I had integrated the Open API Tools with Spring boot apps with Virtualan. Now it is available via https://oss.sonatype.org/content/repositories/releases/io/virtualan/virtualan-plugin/1.0.0 - the first version of virtualan..
I had updated my pull request(#196) with virtualan-plugin. Hope this should be good to proceed further.. Let me know anything else needed.

@jmini
Copy link
Member

jmini commented Aug 30, 2018

Where is the repository holding the sources?

Why are you not hosting your released jar on maven central?

@elans3
Copy link
Contributor Author

elans3 commented Aug 30, 2018

Yes it is available in the maven repo. https://repo.maven.apache.org/maven2/io/virtualan/virtualan-plugin/
Source Code: I am hosting under my own organisation(https://github.com/elan-venture/virtualan).

"artifactId": "springboot-virtualan",
"library": "spring-boot",
"virtualService": true,
"modelPackage" : "org.openapitools.virtualan.model",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion: use spaces instead of tab

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the tab spaces

@@ -232,6 +232,9 @@
public static final String GENERATE_MODELS = "generateModels";
public static final String GENERATE_MODEL_DOCS = "generateModelDocs";

public static final String VIRTUAL_SERVICE = "virtualService";
public static final String VIRTUAL_SERVICE_DOCS = "virtualServiceDocs";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor suggestion: I would suggest replace with virtualServiceDocs with a better description of the service

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated as Suggested

@@ -113,6 +116,7 @@ public SpringCodegen() {
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers", async));
cliOptions.add(CliOption.newBoolean(REACTIVE, "wrap responses in Mono/Flux Reactor types (spring-boot only)", reactive));
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
cliOptions.add(CliOption.newBoolean(VIRTUAL_SERVICE, "Default generate without virtual service"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated with Wiki reference.

<version>1.5.9.RELEASE</version>
</dependency>
<!-- END Virtual Service API support -->
{{/virtualService}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it consistent with the rest of the pom file, please use spaces instead of tabs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the Tab spaces

@wing328 wing328 added this to the 3.3.0 milestone Sep 4, 2018
@wing328
Copy link
Member

wing328 commented Sep 4, 2018

@elans3 I ran /bin/sh ./bin/springboot-virtualan-petstore-server.sh and got the following update:

--- a/samples/server/petstore/springboot-virtualan/README.md
+++ b/samples/server/petstore/springboot-virtualan/README.md
@@ -1,29 +1,18 @@
 # OpenAPI generated server

-Spring Boot Virtual API Service using Virtulan: https://github.com/elan-venture/virtualan/wiki
+Spring Boot Server


 ## Overview
-This virtual service was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
-By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a virtual service.
-This is an example of building a OpenAPI-enabled virtual service in Java using the SpringBoot framework.
+This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
+By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
+This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.

-The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox) and Virtualan (https://github.com/elan-venture/virtualan)
+The underlying library integrating OpenAPI to SpringBoot is [springfox](https://github.com/springfox/springfox)

-Build:
+Start your server as a simple java application

-  mvn clean install
+You can view the api documentation in swagger-ui by pointing to
+http://localhost:80/

-Run using standalone JAR:
-
-  java -jar target/virtualan-spring-controller-example-1.0.0.jar
-
-Invoke User REST service:
-
-  curl http://localhost/users
-
-Invoke Virtualan UI:
-
-Navigate to http://localhost/virtualan-ui.html.
-
-More details about the user interface refer- https://github.com/elan-venture/virtualan/wiki
\ No newline at end of file
+Change default port value in application.properties
\ No newline at end of file

Looks like all the Virtualan related information are gone. Did you see similar update when running the script locally?

@elans3
Copy link
Contributor Author

elans3 commented Sep 4, 2018

@wing328.. Updated the code to generate the "README.md" including Virtualan information on the fly.
Hope it resolves now :)

@wing328
Copy link
Member

wing328 commented Sep 5, 2018

@elans3 thanks for the quick fix. The change looks good to me.

@wing328 wing328 merged commit 3abeb82 into OpenAPITools:master Sep 5, 2018
@elans3
Copy link
Contributor Author

elans3 commented Sep 9, 2018

@wing328.. Thank you!!!

@wing328
Copy link
Member

wing328 commented Oct 2, 2018

@elans3 thanks again for the PR, which is included in the v3.3.0 minor release: https://twitter.com/oas_generator/status/1046941449609068544

@elans3
Copy link
Contributor Author

elans3 commented Oct 3, 2018

Thank you!!!

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Open Virtualan API Implementation

* Menu change

* Delete .swagger-codegen-ignore

* Delete jsonbeautifier.html

* Supporting files for Virtual service setup

* CRLF removed

* Unwanted new lines are removed

* Build issues resolved

* Build issue resolved

* Removed Logger statement

* Logger removed

* Updated

* Codegen virtual services samples for petstore.yaml

* - Code Revamp and Clean up
- Maven plugin related changes
- Samples added

* Tab space removed..

* Annotation based Service virtualization

* Open API code generator changes

* Virtualan samples added with Sprint boot app.

* Build issue resolved

* Removed unwanted files

* Updated with version 3.0.3 SNAPSHOT

* Reverted the options for virtual service in global and not needed now.

* virtualan-plugin integration with open api tool.

* Updated the all review comments and removed all tab spaces.

* Updated the ReadMe generator section.

* New line removed to fix the build issue.

* Spring boot virtualan included in the spring build script

* Included in the spring-all-petstore script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants