Skip to content

Commit 735f7ad

Browse files
committed
Initial commit
0 parents  commit 735f7ad

104 files changed

Lines changed: 4554 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
keep_existing_linebreaks = true
11+
max_line_length = off
12+
13+
[*.{json,xml,yml,yaml,htm,html,js,ts,css,scss,less}]
14+
indent_size = 2
15+
16+
[*.{*proj,resx,config,ruleset,cd,props,targets,nuspec}]
17+
end_of_line = crlf
18+
indent_size = 2
19+
20+
[*.{txt,cs,ps1,psd1,manifest}]
21+
end_of_line = crlf
22+
23+
[*.{bat,cmd}]
24+
charset = latin1
25+
end_of_line = crlf
26+
27+
[*.sln]
28+
end_of_line = crlf
29+
indent_style = tab
30+
31+
[*.{md,resx,Designer.*}]
32+
trim_trailing_whitespace = false
33+
34+
[*.cs]
35+
# Indentation
36+
csharp_indent_block_contents = true
37+
csharp_indent_braces = false
38+
csharp_indent_case_contents = true
39+
csharp_indent_switch_labels = true
40+
csharp_outdent_binary_ops = true
41+
csharp_outdent_dots = true
42+
csharp_align_linq_query = true
43+
csharp_align_multiline_parameter = true
44+
csharp_align_multiline_calls_chain = true
45+
csharp_align_multiline_binary_expressions_chain = true
46+
csharp_align_multiline_array_and_object_initializer = false
47+
48+
# Line breaks
49+
csharp_new_line_before_catch = true
50+
csharp_new_line_before_else = true
51+
csharp_new_line_before_finally = true
52+
csharp_new_line_before_members_in_object_initializers = false
53+
csharp_new_line_before_open_brace = all
54+
csharp_blank_lines_around_single_line_field = 0
55+
csharp_blank_lines_inside_region = 0
56+
csharp_blank_lines_around_region = 0
57+
csharp_blank_lines_after_block_statements = 0
58+
csharp_empty_block_style = together
59+
csharp_place_simple_blocks_on_single_line = true
60+
csharp_place_simple_initializer_on_single_line = true
61+
csharp_place_attribute_on_same_line = if_owner_is_single_line
62+
csharp_place_expr_method_on_single_line = true
63+
csharp_place_constructor_initializer_on_same_line = false
64+
csharp_wrap_object_and_collection_initializer_style = chop_if_long
65+
csharp_wrap_array_initializer_style = chop_if_long
66+
csharp_wrap_parameters_style = chop_if_long
67+
csharp_preserve_single_line_blocks = true
68+
csharp_keep_existing_arrangement = true
69+
70+
# Spacing
71+
csharp_space_after_cast = false
72+
csharp_space_after_colon_in_inheritance_clause = true
73+
csharp_space_after_comma = true
74+
csharp_space_after_dot = false
75+
csharp_space_after_keywords_in_control_flow_statements = true
76+
csharp_space_after_semicolon_in_for_statement = true
77+
csharp_space_around_binary_operators = before_and_after
78+
csharp_space_before_colon_in_inheritance_clause = true
79+
csharp_space_before_comma = false
80+
csharp_space_before_dot = false
81+
csharp_space_before_semicolon_in_for_statement = false
82+
csharp_space_before_open_square_brackets = false
83+
csharp_space_between_empty_square_brackets = false
84+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
85+
csharp_space_between_method_declaration_parameter_list_parentheses = false
86+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
87+
csharp_space_between_method_call_name_and_opening_parenthesis = false
88+
csharp_space_between_method_call_parameter_list_parentheses = false
89+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
90+
csharp_space_between_square_brackets = false
91+
csharp_space_within_empty_braces = false
92+
93+
# Style
94+
csharp_parentheses_redundancy_style = remove_if_not_clarifies_precedence
95+
csharp_allow_comment_after_lbrace = true
96+
csharp_braces_for_ifelse = required_for_multiline
97+
csharp_braces_for_for = required_for_multiline
98+
csharp_braces_for_foreach = required_for_multiline
99+
csharp_braces_for_while = required_for_multiline
100+
csharp_braces_for_using = required_for_multiline
101+
csharp_braces_for_lock = required_for_multiline
102+
csharp_braces_for_fixed = required_for_multiline
103+
csharp_style_var_for_built_in_types = false
104+
csharp_style_var_when_type_is_apparent = true
105+
csharp_style_expression_bodied_constructors = false
106+
csharp_style_expression_bodied_accessors = true
107+
csharp_style_expression_bodied_methods = true
108+
csharp_style_expression_bodied_properties = true
109+
csharp_local_function_body = expression_body
110+
csharp_style_qualification_for_event = false
111+
csharp_style_qualification_for_field = false
112+
csharp_style_qualification_for_method = false
113+
csharp_style_qualification_for_property = false
114+
csharp_style_pattern_matching_over_as_with_null_check = true
115+
csharp_style_pattern_matching_over_is_with_cast_check = true
116+
csharp_style_object_initializer = true
117+
csharp_style_collection_initializer = true
118+
csharp_style_explicit_tuple_names = true
119+
csharp_style_null_propagation = true
120+
csharp_style_coalesce_expression = true
121+
csharp_style_conditional_delegate_call = true
122+
csharp_style_throw_expression = true
123+
csharp_style_predefined_type_for_locals_parameters_members = true
124+
csharp_style_predefined_type_for_member_access = true

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Disable linebreak normalization
2+
* -text

.github/workflows/build.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-latest
7+
steps:
8+
# Prepare
9+
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
12+
- uses: gittools/actions/gitversion/setup@v0.10.2
13+
with:
14+
versionSpec: '5.12.x'
15+
- uses: gittools/actions/gitversion/execute@v0.10.2
16+
id: gitversion
17+
- name: Set version (release)
18+
if: github.ref_type == 'tag'
19+
run: echo "VERSION=${{steps.gitversion.outputs.semVer}}" >> $GITHUB_ENV
20+
- name: Set version (pre-release)
21+
if: github.ref_type != 'tag'
22+
run: echo "VERSION=${{steps.gitversion.outputs.semVer}}-${{steps.gitversion.outputs.shortSha}}" >> $GITHUB_ENV
23+
24+
# Build
25+
- run: gradle build
26+
- run: gradle dokkaHtml
27+
- run: gradle test
28+
- name: Report test results
29+
if: always()
30+
uses: dorny/test-reporter@v1
31+
with:
32+
name: Test Report
33+
reporter: java-junit
34+
path: '*/build/test-results/test/TEST-*.xml'
35+
36+
# Release
37+
- name: Create GitHub Release
38+
if: github.ref_type == 'tag'
39+
uses: softprops/action-gh-release@v1
40+
41+
# Publish
42+
# - name: Publish packages (GitHub)
43+
# if: github.event_name == 'push' && !startsWith(github.ref_name, 'renovate/')
44+
# run: gradle publishMavenPublicationToGitHubRepository
45+
# env:
46+
# GITHUB_TOKEN: ${{github.token}}
47+
# - name: Publish packages (Maven Central)
48+
# if: github.ref_type == 'tag'
49+
# run: gradle publishToSonatype closeAndReleaseSonatypeStagingRepository
50+
# env:
51+
# SIGNING_KEY: ${{secrets.SIGNING_KEY}}
52+
# SIGNING_PASSWORD: ${{secrets.SIGNING_PASSWORD}}
53+
# SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}
54+
# SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}}
55+
- name: Publish documentation
56+
if: github.ref_type == 'tag'
57+
uses: peaceiris/actions-gh-pages@v3
58+
with:
59+
github_token: ${{github.token}}
60+
force_orphan: true
61+
publish_dir: build/dokka/html
62+
cname: java.typedrest.net

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*/build/
2+
/.gradle/
3+
/.idea/
4+
/.kotlin
5+

GitVersion.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mode: ContinuousDeployment
2+
3+
branches:
4+
# Mainline branches
5+
develop:
6+
tag: alpha
7+
increment: patch
8+
master:
9+
tag: beta
10+
11+
# Stabilization branches
12+
release:
13+
tag: rc
14+
hotfix:
15+
tag: rc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2021 Bastian Eicher
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ![TypedRest](logo.svg) for Java/Kotlin
2+
3+
TypedRest for Java/Kotlin helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.
4+
5+
**Java**
6+
7+
```java
8+
MyClient client = new MyClient(URI.create("http://example.com/"));
9+
10+
// GET /contacts
11+
List<Contact> contactList = client.getContacts().readAll();
12+
13+
// POST /contacts -> Location: /contacts/1337
14+
ContactEndpoint smith = client.getContacts().create(new Contact("Smith"));
15+
//ContactEndpoint smith = client.getContacts().get("1337");
16+
17+
// GET /contacts/1337
18+
Contact contact = smith.read();
19+
20+
// PUT /contacts/1337/note
21+
smith.getNote().set(new Note("some note"));
22+
23+
// GET /contacts/1337/note
24+
Note note = smith.getNote().read();
25+
26+
// DELETE /contacts/1337
27+
smith.delete();
28+
```
29+
30+
**Kotlin**
31+
32+
```kotlin
33+
val client = MyClient(URI("http://example.com/"))
34+
35+
// GET /contacts
36+
val contactList: List<Contact> = client.contacts.readAll()
37+
38+
// POST /contacts -> Location: /contacts/1337
39+
val smith: ContactEndpoint = client.contacts.create(Contact("Smith"))
40+
//val smith: ContactEndpoint = client.contacts["1337"]
41+
42+
// GET /contacts/1337
43+
val contact: Contact = smith.read()
44+
45+
// PUT /contacts/1337/note
46+
smith.note.set(Note("some note"))
47+
48+
// GET /contacts/1337/note
49+
val note: Note = smith.note.read()
50+
51+
// DELETE /contacts/1337
52+
smith.delete()
53+
```
54+
55+
Read an **[Introduction](https://typedrest.net/introduction/)** to TypedRest or jump right in with the **[Getting started](https://typedrest.net/getting-started/java/)** guide.
56+
57+
For information about specific classes or interfaces you can read the **[API Documentation](https://java.typedrest.net/)**.
58+
59+
## Maven artifacts
60+
61+
Artifact group: [`net.typedrest`](https://mvnrepository.com/artifact/net.typedrest)
62+
63+
[![typedrest](https://img.shields.io/maven-central/v/net.typedrest/typedrest.svg?label=typedrest)](https://mvnrepository.com/artifact/net.typedrest/typedrest)
64+
The main TypedRest library.
65+
66+
[![typedrest-serializers-jackson](https://img.shields.io/maven-central/v/net.typedrest/typedrest-serializers-jackson.svg?label=typedrest-serializers-jackson)](https://mvnrepository.com/artifact/net.typedrest/typedrest-serializers-jackson)
67+
Adds support for serializing using [Jackson](https://github.com/FasterXML/jackson) instead of [kotlinx.serialization](https://kotlinlang.org/docs/serialization.html).
68+
Pass `new JacksonJsonSerializer()` to the `EntryEndpoint` constructor.
69+
70+
[![typedrest-serializers-moshi](https://img.shields.io/maven-central/v/net.typedrest/typedrest-serializers-moshi.svg?label=typedrest-serializers-moshi)](https://mvnrepository.com/artifact/net.typedrest/typedrest-serializers-moshi)
71+
Adds support for serializing using [Moshi](https://github.com/square/moshi) instead of [kotlinx.serialization](https://kotlinlang.org/docs/serialization.html).
72+
Pass `new MoshiJsonSerializer()` to the `EntryEndpoint` constructor.

build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
kotlin("jvm") version "2.0.0" apply false
3+
kotlin("plugin.serialization") version "2.0.0" apply false
4+
id("org.jetbrains.dokka") version "1.9.20" apply false
5+
}
6+
7+
subprojects {
8+
fun kotlin(module: String) = "org.jetbrains.kotlin.${module}"
9+
apply(plugin = kotlin("jvm"))
10+
apply(plugin = kotlin("plugin.serialization"))
11+
apply(plugin = "org.jetbrains.dokka")
12+
13+
repositories.mavenCentral()
14+
15+
group = "net.typedrest"
16+
version = System.getenv("VERSION") ?: "1.0-SNAPSHOT"
17+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.code.style=official

gradle/libs.versions.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[versions]
2+
okhttp3 = "4.12.0"
3+
uri-templates = "2.1.7"
4+
kotlinx-serialization = "1.7.0"
5+
jackson = "2.17.1"
6+
moshi = "1.15.1"
7+
8+
[libraries]
9+
okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp3" }
10+
okhttp3-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp3" }
11+
uri-templates = { module = "com.damnhandy:handy-uri-templates", version.ref = "uri-templates" }
12+
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
13+
jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
14+
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
15+
moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
16+
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }

0 commit comments

Comments
 (0)