spring-rest-commons-options

DESC

License

License

GroupId

GroupId

com.github.damianwajser
ArtifactId

ArtifactId

spring-rest-commons-options
Last Version

Last Version

0.1.9
Release Date

Release Date

Type

Type

jar
Description

Description

spring-rest-commons-options
DESC
Project URL

Project URL

http://github.com/damianwajser/spring-rest-commons-options
Source Code Management

Source Code Management

https://github.com/damianwajser/spring-rest-commons-options.git

Download spring-rest-commons-options

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.damianwajser/spring-rest-commons-options/ -->
<dependency>
    <groupId>com.github.damianwajser</groupId>
    <artifactId>spring-rest-commons-options</artifactId>
    <version>0.1.9</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.damianwajser/spring-rest-commons-options/
implementation 'com.github.damianwajser:spring-rest-commons-options:0.1.9'
// https://jarcasting.com/artifacts/com.github.damianwajser/spring-rest-commons-options/
implementation ("com.github.damianwajser:spring-rest-commons-options:0.1.9")
'com.github.damianwajser:spring-rest-commons-options:jar:0.1.9'
<dependency org="com.github.damianwajser" name="spring-rest-commons-options" rev="0.1.9">
  <artifact name="spring-rest-commons-options" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.damianwajser', module='spring-rest-commons-options', version='0.1.9')
)
libraryDependencies += "com.github.damianwajser" % "spring-rest-commons-options" % "0.1.9"
[com.github.damianwajser/spring-rest-commons-options "0.1.9"]

Dependencies

compile (6)

Group / Artifact Type Version
org.apache.commons : commons-lang3 jar 3.7
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.9.2
com.fasterxml.jackson.module : jackson-module-jsonSchema jar 2.9.2
org.hibernate.validator : hibernate-validator jar 6.0.4.Final
org.hibernate : hibernate-annotations jar 3.5.6-Final
org.springframework.boot : spring-boot-starter-test jar 1.5.8.RELEASE

provided (5)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 1.5.8.RELEASE
org.springframework.data : spring-data-commons-core jar 1.4.1.RELEASE
org.springframework : spring-core jar 4.3.13.RELEASE
com.fasterxml.jackson.core : jackson-databind jar 2.9.2
javax.validation : validation-api jar 1.1.0.Final

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.0.0-M2
org.junit.jupiter : junit-jupiter-engine jar 5.0.0-M2

Project Modules

There are no modules declared in this project.

spring-rest-commons-options

Build Status CII Best Practices Maven Central Maintainability Test Coverage Vulnerabilities

Overview

This project contains the general-purpose documentation to spring rest api http options. Project is licensed under Apache License 2.0.


Roadmap

Consult the proyect for details on the current spring-rest-commons-options roadmap.

Get it!

Install

Maven

Functionality of this package is contained in Java package com.github.damianwajser, and can be used using following Maven dependency:

<properties>
  ...
  <!-- Use the latest version whenever possible. -->
  <options.spring.docs>{lastversion}</options.spring.docs>
  ...
</properties>

<dependencies>
  ...
  <dependency>
    <groupId>com.github.damianwajser</groupId>
    <artifactId>spring-rest-commons-options</artifactId>
    <version>${options.spring.docs}</version>
  </dependency>
  ...
</dependencies>

Gradle

compile 'com.github.damianwajser:spring-rest-commons-options:0.0.17'

Usage

Create a spring-boot application.

//declare the package to create de options controllers
@ComponentScan({"com.github.damianwajser","{YOUR-PINCIPAL-PACKAGE}"})
@SpringBootApplication
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
  
}

Example

Create the model, if you required, add the validation with the hibernate-validators or java-validators:

public class Example {
	@NotEmpty(message = "The field description is required")
	private String description;

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}

Create a Controller:

@RestController
@RequestMapping("/example")
public class ExapmleResource {
	
	@GetMapping("/{id}")
	public Example getById(@PathVariable("id") Integer id) {
		Example example = new Example();
		example.setDescription("description");
		return example;

	}
	
	@PostMapping("/")
	public Example post(@Valid Example example) {
		return example;

	}
}

Full example: https://github.com/damianwajser/spring-rest-commons-options-example

Test It!!

The firts enpooint created:

curl -X GET http://localhost:8080/endpoints

The response:

["/example","/endpoints"]

Check options

curl -X OPTIONS http://localhost:8080/example

Response:

{
    "resources": {
        "/example": {
            "endpoints": [
                {
                    "endpoint": "GET - /example/{id}",
                    "httpMethod": "GET",
                    "relativeUrl": "/{id}",
                    "queryString": {
                        "params": []
                    },
                    "pathVariable": {
                        "params": [
                            {
                                "required": true,
                                "name": "id",
                                "type": "Integer"
                            }
                        ]
                    },
                    "bodyRequest": {
                        "fields": [],
                        "jsonSchema": null
                    },
                    "bodyResponse": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "headers": [],
                    "url": "/example/{id}"
                },
                {
                    "endpoint": "GET - /example/{id}",
                    "httpMethod": "GET",
                    "relativeUrl": "/{id}",
                    "queryString": {
                        "params": []
                    },
                    "pathVariable": {
                        "params": [
                            {
                                "required": true,
                                "name": "id",
                                "type": "Integer"
                            }
                        ]
                    },
                    "bodyRequest": {
                        "fields": [],
                        "jsonSchema": null
                    },
                    "bodyResponse": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "headers": [],
                    "url": "/example/{id}"
                },
                {
                    "endpoint": "POST - /example",
                    "httpMethod": "POST",
                    "relativeUrl": "",
                    "queryString": {
                        "params": []
                    },
                    "pathVariable": {
                        "params": []
                    },
                    "bodyRequest": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false,
                                "validation": [
                                    {
                                        "name": "NotEmpty",
                                        "message": "The field description is required"
                                    }
                                ]
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "bodyResponse": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "headers": [],
                    "url": "/example"
                },
                {
                    "endpoint": "POST - /example",
                    "httpMethod": "POST",
                    "relativeUrl": "",
                    "queryString": {
                        "params": []
                    },
                    "pathVariable": {
                        "params": []
                    },
                    "bodyRequest": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false,
                                "validation": [
                                    {
                                        "name": "NotEmpty",
                                        "message": "The field description is required"
                                    }
                                ]
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "bodyResponse": {
                        "fields": [
                            {
                                "name": "description",
                                "type": "String",
                                "auditable": false
                            }
                        ],
                        "jsonSchema": {
                            "type": "object",
                            "id": "urn:jsonschema:com:test:damianwajser:model:Example",
                            "properties": {
                                "description": {
                                    "type": "string"
                                }
                            }
                        }
                    },
                    "headers": [],
                    "url": "/example"
                }
            ]
        }
    },
    "httpCodes": {}
}

License

The Spring Framework is released under version 2.0 of the Apache License.

Versions

Version
0.1.9
0.1.8
0.1.5-
0.1.3
0.1.0
0.0.20
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8