GitXplorerGitXplorer
k

api-stub

public
8 stars
7 forks
11 issues

Commits

List of commits on branch master.
Unverified
9a9f50e5c09c9ad0b9adfa05edd6bc9d7dfdce84

Upgrade to Maven Wrapper 0.4.2

kkazuki43zoo committed 6 years ago
Unverified
3f260245136a4d48a436994f428ef0498759b73a

Merge branch 'master' of https://github.com/kazuki43zoo/api-stub

kkazuki43zoo committed 6 years ago
Unverified
01c4b1ad3115993d71402f41b8c7a4b12bcb60fa

Upgrade to Spring Boot 2.0.6

kkazuki43zoo committed 6 years ago
Verified
68d677f385aebcf19a03b78cdd9f263f21b89220

Update README.md

kkazuki43zoo committed 6 years ago
Unverified
81826d2864937d494d84e6e744b7d94177a20ebf

Improve

kkazuki43zoo committed 7 years ago
Unverified
f44bd7c070130826b15f04b2ffebff674356edb2

Improve

kkazuki43zoo committed 7 years ago

README

The README file for this repository.

Build Status Dependency Status Codacy Badge

api-stub

Stub for API

Requirements for Maven compile and runtime

  • Java SE 8 (JDK 1.8)

Getting started !!

  • Download the api-stub.jar and save to any directory

  • Run the application

    $ java -jar api-stub.jar

    Note: How to change server port

    Default server port is 8080. If you want to change server port, please run application as follow (adding --server.port=xxxx):

    e.g.)

    $ java -jar api-stub.jar --server.port=9999
  • Stop the application (Type "Ctrl + C")

Try to access mock API

Default response (404 NOT FOUND)

  • Access to an unknown path

    $ curl -D - http://localhost:8080/api/v1/test
    HTTP/1.1 404 
    x-correlation-id: 0dbb5f82-da1e-4e5d-9d3a-64408b4db6e7
    Content-Length: 0
    Date: Wed, 19 Jul 2017 18:45:39 GMT
    
    

Mock response

  • Open the management screen

    http://localhost:8080/

    List for mock response

  • Add a new mock response

    Add for mock response

  • Access to the creating path

    $ curl -D - http://localhost:8080/api/v1/members/1
    HTTP/1.1 200 
    x-correlation-id: 9b8c538c-a3fd-478e-b62c-d0116c44c0ba
    Content-Type: application/json;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Sun, 23 Oct 2016 07:36:58 GMT
    
    {
        "name" : "kazuki43zoo"
    }
    

Evidence

Evidence(request headers, request parameters, request body and upload files) are outoutting the evidence directory on your application root.

${WORKING_DIR}/evidence
└─api
   └─v1
     └─members
         └─1 (* request path)
           └─GET (* http method)
              └─20161023163658842_9b8c538c-a3fd-478e-b62c-d0116c44c0ba (* ${datetime}_${x-correlation-id})
                  + request.json (* include http headers, request parameters)
                  + body.txt (* request body)
                  + uploadFile_01_xxxx.png (* upload files)

Console logs

Access logs are outputting the console.

...
2016-10-23 16:36:58.842  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Start.
2016-10-23 16:36:58.842  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Evidence Dir : /Users/xxxx/api-stub/evidence/api/v1/members/1/GET/20161023163658842_9b8c538c-a3fd-478e-b62c-d0116c44c0ba
2016-10-23 16:36:58.843  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Request      : {"parameters":{},"headers":{"host":["localhost:8080"],"user-agent":["curl/7.43.0"],"accept":["*/*"]}}
2016-10-23 16:36:58.843  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Request body : empty
2016-10-23 16:36:58.844  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Mock Response is 1.
2016-10-23 16:36:58.845  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : Response     : {"httpStatus":"OK","headers":{"Content-Type":["application/json"],"x-correlation-id":["9b8c538c-a3fd-478e-b62c-d0116c44c0ba"]}}
2016-10-23 16:36:58.845  INFO 48685 --- [nio-8080-exec-1] GET /api/v1/members/1                    : End.
...

Access the database

You can access the database directly.

Using H2 admin console

http://localhost:8080/h2-console/

Item Value
Driver Class org.h2.Driver
JDBC URL jdbc:h2:~/db/api-stub
User Name sa
Password

Using JDBC Driver on client tool

Please download jdbc driver on here.

Item Value
Driver Class org.h2.Driver
JDBC URL jdbc:h2:tcp://localhost/~/db/api-stub
User sa
Password

Appendix

Requirements for IDE

Install the Lombok

If you use a IDE(STS, IDEA, etc...), please install the lombok. About how to install the lombok, please see as follows:

Groovy Eclipse

If you use a STS(or Eclipse), please install the Groovy Eclipse plugin. About how install the Groovy Eclipse, please see as follow:

How to build and run

Known Issues

Feature request and bug report