-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
2,006 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...c/main/java/com/github/muehmar/gradle/openapi/typemappingwithconversion/CustomString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.github.muehmar.gradle.openapi.typemappingwithconversion; | ||
|
||
import java.util.Objects; | ||
|
||
public class CustomString { | ||
private final String value; | ||
|
||
public static CustomString fromString(String value) { | ||
return new CustomString(value); | ||
} | ||
|
||
public CustomString(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final CustomString that = (CustomString) o; | ||
return Objects.equals(value, that.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CustomString{" + "value='" + value + '\'' + '}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
|
||
FullObject: | ||
oneOf: | ||
- $ref: '#/components/schemas/Admin' | ||
- $ref: '#/components/schemas/User' | ||
|
||
NestedFullObject: | ||
required: | ||
- amount | ||
anyOf: | ||
- $ref: '#/components/schemas/FullObject' | ||
- $ref: '#/components/schemas/Member' | ||
properties: | ||
amount: | ||
type: integer | ||
|
||
User: | ||
required: | ||
- type | ||
- username | ||
properties: | ||
type: | ||
type: string | ||
username: | ||
type: string | ||
|
||
Admin: | ||
required: | ||
- type | ||
- adminname | ||
properties: | ||
type: | ||
type: string | ||
adminname: | ||
type: string | ||
nullable: true | ||
|
||
Member: | ||
required: | ||
- type | ||
- membername | ||
properties: | ||
type: | ||
type: string | ||
membername: | ||
type: string | ||
|
178 changes: 178 additions & 0 deletions
178
example/src/main/resources/openapi-type-mapping-with-conversion.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
openapi: "3.0.0" | ||
info: { } | ||
|
||
paths: { } | ||
|
||
components: | ||
schemas: | ||
User: | ||
required: | ||
- id | ||
- username | ||
properties: | ||
id: | ||
type: string | ||
minLength: 6 | ||
maxLength: 10 | ||
username: | ||
type: string | ||
nullable: true | ||
minLength: 5 | ||
maxLength: 20 | ||
email: | ||
type: string | ||
pattern: '[A-Za-z0-9]+@[A-Za-z0-9]+\.[a-z]+' | ||
phone: | ||
type: string | ||
nullable: true | ||
pattern: '\+41[0-9]{7}' | ||
additionalProperties: | ||
type: string | ||
nullable: true | ||
|
||
ListObject: | ||
required: | ||
- ids | ||
- usernames | ||
properties: | ||
ids: | ||
type: array | ||
items: | ||
type: string | ||
nullable: true | ||
minLength: 6 | ||
maxLength: 10 | ||
minItems: 1 | ||
maxItems: 2 | ||
usernames: | ||
type: array | ||
items: | ||
type: string | ||
nullable: true | ||
minLength: 9 | ||
maxLength: 12 | ||
nullable: true | ||
minItems: 3 | ||
maxItems: 4 | ||
emails: | ||
type: array | ||
items: | ||
type: string | ||
nullable: true | ||
pattern: '[a-z]+-[0-9]{4}' | ||
minItems: 5 | ||
maxItems: 6 | ||
phones: | ||
type: array | ||
items: | ||
type: string | ||
nullable: true | ||
pattern: 'phone-[0-9]{4}' | ||
minItems: 7 | ||
maxItems: 8 | ||
nullable: true | ||
additionalProperties: | ||
type: string | ||
|
||
MapObject: | ||
type: object | ||
required: | ||
- idsMap | ||
- usernamesMap | ||
properties: | ||
idsMap: | ||
additionalProperties: | ||
type: string | ||
minLength: 6 | ||
maxLength: 10 | ||
usernamesMap: | ||
nullable: true | ||
additionalProperties: | ||
type: string | ||
nullable: true | ||
minLength: 9 | ||
maxLength: 12 | ||
emailsMap: | ||
additionalProperties: | ||
type: string | ||
nullable: true | ||
pattern: '[a-z]+-[0-9]{4}' | ||
phonesMap: | ||
nullable: true | ||
additionalProperties: | ||
type: string | ||
nullable: true | ||
pattern: 'phone-[0-9]{4}' | ||
|
||
AllOfListObject: | ||
allOf: | ||
- $ref: '#/components/schemas/ListObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
OneOfListObject: | ||
oneOf: | ||
- $ref: '#/components/schemas/ListObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
AnyOfListObject: | ||
anyOf: | ||
- $ref: '#/components/schemas/ListObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
AllOfMapObject: | ||
allOf: | ||
- $ref: '#/components/schemas/MapObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
OneOfMapObject: | ||
oneOf: | ||
- $ref: '#/components/schemas/MapObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
AnyOfMapObject: | ||
anyOf: | ||
- $ref: '#/components/schemas/MapObject' | ||
- type: object | ||
properties: | ||
superUserId: | ||
type: string | ||
|
||
Posology: | ||
description: | | ||
Doses to be taken (morning, midday, evening, night). Used for | ||
package size calculation. | ||
type: array | ||
maxItems: 4 | ||
items: | ||
type: string | ||
minLength: 1 | ||
example: | ||
- "1" | ||
- "0" | ||
- "2" | ||
- "0" | ||
|
||
ArrayAdditionalProperties: | ||
type: object | ||
additionalProperties: | ||
type: array | ||
items: | ||
type: string | ||
|
||
|
||
|
13 changes: 13 additions & 0 deletions
13
example/src/test/java/com/github/muehmar/gradle/openapi/Lists.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.github.muehmar.gradle.openapi; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Lists { | ||
private Lists() {} | ||
|
||
@SafeVarargs | ||
public static <T> List<T> list(T... elements) { | ||
return Arrays.asList(elements); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
example/src/test/java/com/github/muehmar/gradle/openapi/Maps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.github.muehmar.gradle.openapi; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Maps { | ||
private Maps() {} | ||
|
||
public static <K, V> Map<K, V> map(K key, V value) { | ||
return Collections.singletonMap(key, value); | ||
} | ||
|
||
public static <K, V> Map<K, V> map(K key1, V value1, K key2, V value2) { | ||
final HashMap<K, V> map = new HashMap<>(); | ||
map.put(key1, value1); | ||
map.put(key2, value2); | ||
return Collections.unmodifiableMap(map); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
example/src/test/java/com/github/muehmar/gradle/openapi/Optionals.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.github.muehmar.gradle.openapi; | ||
|
||
import java.util.Optional; | ||
|
||
public class Optionals { | ||
private Optionals() {} | ||
|
||
public static <T> Optional<T> opt(T value) { | ||
return Optional.of(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.