Friday, 18 October 2019

Amazing Use of Swagger Contract YAML

REST based micro-services is current day trend to develop application over HTTP communication. 

We have choice to follow either "CONTRACT FIRST" or "CONTRACT LAST".

My personal choice is "CONTRACT FIRST". It has numerous advantages - few of them are:-


  1. Request and Response is framed upfront and Swagger (YAML) contract is developed and published for its prospective clients.
  2.  Early feedback.
  3. Quick turn-around to market.       
source:internet

Another vital benefits is that developed Swagger can reduce your micro-service development time by approx HALF.

Don't get Surprised!  Keep reading.

Follow below step in your Spring-boot project and generate controller Interface, Models etc upfront and simply focus on service logic in your micro-service.

All steps are to be incorporated in your POM.xml

1. Add path- of your swagger yaml file in project.
<properties>
<jsonFilePath>src/main/resources/dev/1.0.0/xyz.yaml</jsonFilePath>
</properties>


2. Add maven swagger codegen plugin and you are done.

<build>
    <plugins>
        <plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>${swagger-codegen-maven-plugin-version}</version>
    <executions>
        <execution>
            <id>generate-api</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${jsonFilePath}</inputSpec>
                <language>spring</language>
                <output>${project.build.directory}/generated-sources/swagger</output>
                <apiPackage>com.abc.swagger.api</apiPackage>
                <modelPackage>com.abc.swagger.model</modelPackage>
                <invokerPackage>com.abc.swagger.invoker</invokerPackage>
                <environmentVariables>
                    <dateLibrary>java8</dateLibrary>
                    <models/>
                    <apis/>
                    <supportingFilesToGenerate>SwaggerDocumentationConfig.java,HomeController.java
                    </supportingFilesToGenerate>
                </environmentVariables>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <executions>
        <execution>
            <id>clean-additional-generated-files</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>clean</goal>
            </goals>
            <configuration>
                <excludeDefaultDirectories>true</excludeDefaultDirectories>
                <filesets>
                    <fileset>
                        <directory>${project.build.directory}/generated-sources/swagger</directory>
                        <excludes>
                            <exclude>src/main/java/**</exclude>
                        </excludes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </execution>
    </executions>
</plugin>
    </plugins>
</build>

--------------------**-------------------

For details TDD and quality REST micro-services development refer course at UDEMY.com



Thank you!



Satender Kumar Mall
Twitter: @satenderiiit





Sunday, 13 October 2019

Choice Vs Compulsion



If we do things by choice- The greatest benefits is -we know when to start & when to stop! It is step toward freedom and realising the sensitivity of life.

If we do by compulsion- What we start, we cannot stop. We get enslaved.

But this does not mean - we should become food fanatic - Irritate people around us by repeating "I don't eat this, i don't eat that, i just eat this"

source: internet

However the broader messages is simple- eat by choice but don't get enslaved ...

Let's have a look around- Many of us are knowingly or unknowingly enslaved to TEA/COFFEE and many other nervous system stimulus food.

There are positive pranic as well as negative pranic food. The food should be taken based on body needs.

Few example of positive pranic foods are: Honey, Black pepper, Ash-gourd (Winter melon) etc.

To eat is a necessity

But, to eat intelligently is an Art



The word pranic stems from the Sanskrit word "prana" meaning "vital life force" which is an ancient science and art of healing that utilizes prana or ki energy to heal the whole physical body. (definition taken from internet)



Thank you!



Satender Kumar Mall
Twitter: @satenderiiit