From 0081ebf801525cf340c73dcd1ba3ae5beae9913e Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Fri, 29 May 2020 08:33:36 +0200 Subject: [PATCH 01/12] Update swagger and swagger-codegen The Pan class from the `importMappings>` has an import statement now --- code-first-swagger/pom.xml | 2 +- design-first-swagger-openliberty/pom.xml | 4 ++-- .../src/test/resources/PinCheckRequest.java.txt | 9 +++++---- .../src/test/resources/PurchaseAuthRequest.java.txt | 9 +++++---- design-first-swagger-quarkus/pom.xml | 4 ++-- .../src/test/resources/PinCheckRequest.java.txt | 9 +++++---- .../src/test/resources/PurchaseAuthRequest.java.txt | 9 +++++---- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 822ae9c..6ec497a 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -19,7 +19,7 @@ 1.18.10 0.25.0 - 2.0.10 + 2.1.2 2.2 diff --git a/design-first-swagger-openliberty/pom.xml b/design-first-swagger-openliberty/pom.xml index 91668c3..eed1e05 100644 --- a/design-first-swagger-openliberty/pom.xml +++ b/design-first-swagger-openliberty/pom.xml @@ -21,8 +21,8 @@ 2.10.0 1.18.10 19.0.0.10 - 2.0.10 - 3.0.11 + 2.1.2 + 3.0.20 5.5.2 diff --git a/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt b/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt index c36d8a9..d23a3e6 100644 --- a/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt @@ -14,6 +14,7 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -26,7 +27,7 @@ import java.util.UUID; public class PinCheckRequest { @JsonProperty("pan") - private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; + private Pan pan = null; @JsonProperty("pinBlock") private String pinBlock = null; @@ -34,7 +35,7 @@ public class PinCheckRequest { @JsonProperty("uuid") private UUID uuid = null; - public PinCheckRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public PinCheckRequest pan(Pan pan) { this.pan = pan; return this; } @@ -44,11 +45,11 @@ public class PinCheckRequest { * @return pan **/ @Schema(required = true, description = "") - public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { + public Pan getPan() { return pan; } - public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public void setPan(Pan pan) { this.pan = pan; } diff --git a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt index 07091bc..a850e51 100644 --- a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt @@ -15,6 +15,7 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; +import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -30,7 +31,7 @@ public class PurchaseAuthRequest { private EmvTags emvTags = null; @JsonProperty("pan") - private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; + private Pan pan = null; @JsonProperty("uuid") private UUID uuid = null; @@ -53,7 +54,7 @@ public class PurchaseAuthRequest { this.emvTags = emvTags; } - public PurchaseAuthRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public PurchaseAuthRequest pan(Pan pan) { this.pan = pan; return this; } @@ -63,11 +64,11 @@ public class PurchaseAuthRequest { * @return pan **/ @Schema(required = true, description = "") - public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { + public Pan getPan() { return pan; } - public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public void setPan(Pan pan) { this.pan = pan; } diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index e2e540a..afefe68 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -21,8 +21,8 @@ 2.9.9.3 1.18.10 0.25.0 - 2.0.10 - 3.0.11 + 2.1.2 + 3.0.20 2.2 diff --git a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt index 326102d..af54c7f 100644 --- a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt @@ -14,6 +14,7 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -26,7 +27,7 @@ import java.util.UUID; public class PinCheckRequest { @JsonProperty("pan") - private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; + private Pan pan = null; @JsonProperty("pinBlock") private String pinBlock = null; @@ -34,7 +35,7 @@ public class PinCheckRequest { @JsonProperty("uuid") private UUID uuid = null; - public PinCheckRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public PinCheckRequest pan(Pan pan) { this.pan = pan; return this; } @@ -44,11 +45,11 @@ public class PinCheckRequest { * @return pan **/ @Schema(required = true, description = "") - public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { + public Pan getPan() { return pan; } - public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public void setPan(Pan pan) { this.pan = pan; } diff --git a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt index 15c0ca3..830cca1 100644 --- a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt @@ -15,6 +15,7 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; +import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -30,7 +31,7 @@ public class PurchaseAuthRequest { private EmvTags emvTags = null; @JsonProperty("pan") - private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; + private Pan pan = null; @JsonProperty("uuid") private UUID uuid = null; @@ -53,7 +54,7 @@ public class PurchaseAuthRequest { this.emvTags = emvTags; } - public PurchaseAuthRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public PurchaseAuthRequest pan(Pan pan) { this.pan = pan; return this; } @@ -63,11 +64,11 @@ public class PurchaseAuthRequest { * @return pan **/ @Schema(required = true, description = "") - public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { + public Pan getPan() { return pan; } - public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { + public void setPan(Pan pan) { this.pan = pan; } From a8e765a6c44d51a9a5b951118c28d560de577f3d Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Fri, 29 May 2020 10:13:10 +0200 Subject: [PATCH 02/12] Update quarkus to 1.5.0.Final - the MP openapi implementation in Quarkus 1.5.0 (smallrye-openapi 1.2.3) has better decomposition into schemas for the code-first approach - the more recent jackson version in the new quarkus leads to some more quotes in the yaml documents returned from `/openapi` --- code-first-openapi-quarkus/pom.xml | 2 +- .../src/test/resources/openapi-sorted.yaml | 108 ++++++------- .../src/test/resources/openapi.json | 149 +++++++++--------- .../src/test/resources/openapi.yaml | 108 ++++++------- code-first-swagger/pom.xml | 2 +- .../src/test/resources/openapi-sorted.yaml | 4 +- design-first-openapi-generator/pom.xml | 11 +- .../src/test/resources/openapi-sorted.yaml | 4 +- .../src/test/resources/openapi.yaml | 4 +- design-first-swagger-quarkus/pom.xml | 11 +- .../src/test/resources/openapi-sorted.yaml | 4 +- .../src/test/resources/openapi.yaml | 4 +- 12 files changed, 177 insertions(+), 234 deletions(-) diff --git a/code-first-openapi-quarkus/pom.xml b/code-first-openapi-quarkus/pom.xml index 6f60381..cdaf0df 100755 --- a/code-first-openapi-quarkus/pom.xml +++ b/code-first-openapi-quarkus/pom.xml @@ -18,7 +18,7 @@ 1.18.10 - 0.25.0 + 1.5.0.Final 2.2 diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml index 8c2e8bd..6be0740 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml +++ b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml @@ -40,16 +40,37 @@ paths: summary: Authorize a Purchase components: schemas: + Code: + enum: + - OK + - WRONG + type: string + Code1: + enum: + - OK + - WRONG + type: string + EmvTags: + description: Collection of EMV tags + properties: + "84": + description: The EMV AID as reported by ICC + title: Dedicated Filename + type: string + "9F1A": + description: Terminal Country Code + type: string + title: EmvTags + type: object + Pan: + description: The number embossed on credit cards + title: PAN (Primary Account Number) + type: string PinCheckRequest: description: Request for checking a PIN properties: pan: - description: The number embossed on credit cards - properties: - pan: - type: string - title: PAN (Primary Account Number) - type: string + $ref: '#/components/schemas/Pan' pinBlock: description: |- Encrypted binary data containing a PIN @@ -57,21 +78,9 @@ components: Fieldcode: C003 type: string uuid: - description: Unique ID of the request - properties: - leastSigBits: - format: int64 - type: integer - leastSignificantBits: - format: int64 - type: integer - mostSigBits: - format: int64 - type: integer - mostSignificantBits: - format: int64 - type: integer - type: object + allOf: + - $ref: '#/components/schemas/UUID' + - description: Unique ID of the request required: - uuid - pan @@ -81,11 +90,9 @@ components: description: Tells if the PIN in the request was correct properties: result: - description: Result of the request - enum: - - OK - - WRONG - type: string + allOf: + - $ref: '#/components/schemas/Code' + - description: Result of the request tries: description: Number of remaining tries format: int32 @@ -95,40 +102,13 @@ components: description: Request for authorizing a Purchase properties: emvTags: - description: Collection of EMV tags - properties: - 84: - description: The EMV AID as reported by ICC - title: Dedicated Filename - type: string - 9F1A: - description: Terminal Country Code - type: string - title: EmvTags - type: object + $ref: '#/components/schemas/EmvTags' pan: - description: The number embossed on credit cards - properties: - pan: - type: string - title: PAN (Primary Account Number) - type: string + $ref: '#/components/schemas/Pan' uuid: - description: Unique ID of the request - properties: - leastSigBits: - format: int64 - type: integer - leastSignificantBits: - format: int64 - type: integer - mostSigBits: - format: int64 - type: integer - mostSignificantBits: - format: int64 - type: integer - type: object + allOf: + - $ref: '#/components/schemas/UUID' + - description: Unique ID of the request required: - uuid - pan @@ -140,9 +120,11 @@ components: description: Code referencing the successful authorization type: string result: - description: Result of the request - enum: - - OK - - WRONG - type: string + allOf: + - $ref: '#/components/schemas/Code1' + - description: Result of the request type: object + UUID: + format: uuid + pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}' + type: string diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json b/code-first-openapi-quarkus/src/test/resources/openapi.json index 0ba0cd7..3c61aba 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json @@ -1,44 +1,60 @@ { "components": { "schemas": { + "Code": { + "enum": [ + "OK", + "WRONG" + ], + "type": "string" + }, + "Code1": { + "enum": [ + "OK", + "WRONG" + ], + "type": "string" + }, + "EmvTags": { + "description": "Collection of EMV tags", + "properties": { + "84": { + "description": "The EMV AID as reported by ICC", + "title": "Dedicated Filename", + "type": "string" + }, + "9F1A": { + "description": "Terminal Country Code", + "type": "string" + } + }, + "title": "EmvTags", + "type": "object" + }, + "Pan": { + "description": "The number embossed on credit cards", + "title": "PAN (Primary Account Number)", + "type": "string" + }, "PinCheckRequest": { "description": "Request for checking a PIN", "properties": { "pan": { - "description": "The number embossed on credit cards", - "properties": { - "pan": { - "type": "string" - } - }, - "title": "PAN (Primary Account Number)", - "type": "string" + "$ref": "#/components/schemas/Pan" }, "pinBlock": { "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", "type": "string" }, "uuid": { - "description": "Unique ID of the request", - "properties": { - "leastSigBits": { - "format": "int64", - "type": "integer" - }, - "leastSignificantBits": { - "format": "int64", - "type": "integer" - }, - "mostSigBits": { - "format": "int64", - "type": "integer" + "allOf": [ + { + "$ref": "#/components/schemas/UUID" }, - "mostSignificantBits": { - "format": "int64", - "type": "integer" + { + "description": "Unique ID of the request" } - }, - "type": "object" + ] } }, "required": [ @@ -52,12 +68,14 @@ "description": "Tells if the PIN in the request was correct", "properties": { "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "allOf": [ + { + "$ref": "#/components/schemas/Code" + }, + { + "description": "Result of the request" + } + ] }, "tries": { "description": "Number of remaining tries", @@ -71,52 +89,20 @@ "description": "Request for authorizing a Purchase", "properties": { "emvTags": { - "description": "Collection of EMV tags", - "properties": { - "84": { - "description": "The EMV AID as reported by ICC", - "title": "Dedicated Filename", - "type": "string" - }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" - } - }, - "title": "EmvTags", - "type": "object" + "$ref": "#/components/schemas/EmvTags" }, "pan": { - "description": "The number embossed on credit cards", - "properties": { - "pan": { - "type": "string" - } - }, - "title": "PAN (Primary Account Number)", - "type": "string" + "$ref": "#/components/schemas/Pan" }, "uuid": { - "description": "Unique ID of the request", - "properties": { - "leastSigBits": { - "format": "int64", - "type": "integer" - }, - "leastSignificantBits": { - "format": "int64", - "type": "integer" + "allOf": [ + { + "$ref": "#/components/schemas/UUID" }, - "mostSigBits": { - "format": "int64", - "type": "integer" - }, - "mostSignificantBits": { - "format": "int64", - "type": "integer" + { + "description": "Unique ID of the request" } - }, - "type": "object" + ] } }, "required": [ @@ -133,15 +119,22 @@ "type": "string" }, "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "allOf": [ + { + "$ref": "#/components/schemas/Code1" + }, + { + "description": "Result of the request" + } + ] } }, "type": "object" + }, + "UUID": { + "format": "uuid", + "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", + "type": "string" } } }, diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml b/code-first-openapi-quarkus/src/test/resources/openapi.yaml index e372630..0f0946b 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.yaml +++ b/code-first-openapi-quarkus/src/test/resources/openapi.yaml @@ -49,12 +49,7 @@ components: type: object properties: pan: - title: PAN (Primary Account Number) - description: The number embossed on credit cards - type: string - properties: - pan: - type: string + $ref: '#/components/schemas/Pan' pinBlock: description: |- Encrypted binary data containing a PIN @@ -62,35 +57,34 @@ components: Fieldcode: C003 type: string uuid: - description: Unique ID of the request - type: object - properties: - leastSigBits: - format: int64 - type: integer - mostSigBits: - format: int64 - type: integer - leastSignificantBits: - format: int64 - type: integer - mostSignificantBits: - format: int64 - type: integer + allOf: + - $ref: '#/components/schemas/UUID' + - description: Unique ID of the request + Pan: + title: PAN (Primary Account Number) + description: The number embossed on credit cards + type: string + UUID: + format: uuid + pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}' + type: string PinCheckResponse: description: Tells if the PIN in the request was correct type: object properties: result: - description: Result of the request - enum: - - OK - - WRONG - type: string + allOf: + - $ref: '#/components/schemas/Code' + - description: Result of the request tries: format: int32 description: Number of remaining tries type: integer + Code: + enum: + - OK + - WRONG + type: string PurchaseAuthRequest: description: Request for authorizing a Purchase required: @@ -99,40 +93,25 @@ components: type: object properties: emvTags: - title: EmvTags - description: Collection of EMV tags - type: object - properties: - 84: - title: Dedicated Filename - description: The EMV AID as reported by ICC - type: string - 9F1A: - description: Terminal Country Code - type: string + $ref: '#/components/schemas/EmvTags' pan: - title: PAN (Primary Account Number) - description: The number embossed on credit cards - type: string - properties: - pan: - type: string + $ref: '#/components/schemas/Pan' uuid: - description: Unique ID of the request - type: object - properties: - leastSigBits: - format: int64 - type: integer - mostSigBits: - format: int64 - type: integer - leastSignificantBits: - format: int64 - type: integer - mostSignificantBits: - format: int64 - type: integer + allOf: + - $ref: '#/components/schemas/UUID' + - description: Unique ID of the request + EmvTags: + title: EmvTags + description: Collection of EMV tags + type: object + properties: + "84": + title: Dedicated Filename + description: The EMV AID as reported by ICC + type: string + "9F1A": + description: Terminal Country Code + type: string PurchaseAuthResponse: description: Response to PurchaseAuthRequest type: object @@ -141,8 +120,11 @@ components: description: Code referencing the successful authorization type: string result: - description: Result of the request - enum: - - OK - - WRONG - type: string + allOf: + - $ref: '#/components/schemas/Code1' + - description: Result of the request + Code1: + enum: + - OK + - WRONG + type: string diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 6ec497a..8e1c8c4 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -18,7 +18,7 @@ 1.18.10 - 0.25.0 + 1.5.0.Final 2.1.2 diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml b/code-first-swagger/src/test/resources/openapi-sorted.yaml index c142e57..9c064e5 100644 --- a/code-first-swagger/src/test/resources/openapi-sorted.yaml +++ b/code-first-swagger/src/test/resources/openapi-sorted.yaml @@ -45,11 +45,11 @@ components: EmvTags: description: Collection of EMV tags properties: - 84: + "84": description: The EMV AID as reported by ICC title: Dedicated Filename type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string title: EmvTags diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index 6950ae4..052e425 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -17,10 +17,8 @@ 11 - - 2.9.9.3 1.18.10 - 0.25.0 + 1.5.0.Final 1.5.22 4.1.3 @@ -64,12 +62,7 @@ jsr305 3.0.2 - - com.fasterxml.jackson.core - jackson-databind - ${jackson-2-version} - provided - + io.swagger diff --git a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml index d20176c..155311c 100644 --- a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml +++ b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml @@ -47,11 +47,11 @@ components: EmvTags: description: Collection of EMV tags properties: - 84: + "84": description: The EMV AID as reported by ICC title: Dedicated Filename type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string title: EmvTags diff --git a/design-first-openapi-generator/src/test/resources/openapi.yaml b/design-first-openapi-generator/src/test/resources/openapi.yaml index 87d016e..e6103c6 100644 --- a/design-first-openapi-generator/src/test/resources/openapi.yaml +++ b/design-first-openapi-generator/src/test/resources/openapi.yaml @@ -49,11 +49,11 @@ components: description: Collection of EMV tags type: object properties: - 84: + "84": title: Dedicated Filename description: The EMV AID as reported by ICC type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string Pan: diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index afefe68..a4cf5e6 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -17,10 +17,8 @@ 11 - - 2.9.9.3 1.18.10 - 0.25.0 + 1.5.0.Final 2.1.2 3.0.20 @@ -59,12 +57,7 @@ - - com.fasterxml.jackson.core - jackson-databind - ${jackson-2-version} - provided - + io.swagger.core.v3 swagger-annotations diff --git a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml index 6959387..42d2069 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml +++ b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml @@ -47,11 +47,11 @@ components: EmvTags: description: Collection of EMV tags properties: - 84: + "84": description: The EMV AID as reported by ICC title: Dedicated Filename type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string title: EmvTags diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.yaml b/design-first-swagger-quarkus/src/test/resources/openapi.yaml index 1b7ee60..f47e3f5 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi.yaml +++ b/design-first-swagger-quarkus/src/test/resources/openapi.yaml @@ -49,11 +49,11 @@ components: description: Collection of EMV tags type: object properties: - 84: + "84": title: Dedicated Filename description: The EMV AID as reported by ICC type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string Pan: From 9b55c8093bc7a50efa94c6346c8ec890253292c3 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Fri, 29 May 2020 18:33:36 +0200 Subject: [PATCH 03/12] Update openapi-generator to version 4.3.1 This version finally has working importMappings support --- design-first-openapi-generator/pom.xml | 2 +- .../apidocs/openapi/designfirst/rest/TxProc.java | 4 +++- .../src/test/resources/EmvTags.java.txt | 2 -- .../src/test/resources/PinCheckRequest.java.txt | 15 ++++++--------- .../src/test/resources/PinCheckResponse.java.txt | 2 -- .../test/resources/PurchaseAuthRequest.java.txt | 15 ++++++--------- .../test/resources/PurchaseAuthResponse.java.txt | 2 -- 7 files changed, 16 insertions(+), 26 deletions(-) diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index 052e425..7a7396c 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -20,7 +20,7 @@ 1.18.10 1.5.0.Final 1.5.22 - 4.1.3 + 4.3.1 2.2 diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java index 94f97f3..a990d1e 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java @@ -13,6 +13,7 @@ import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.PinCheckResponse; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.PurchaseAuthRequest; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.PurchaseAuthResponse; +import ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan; @Path("/txproc") @Consumes(MediaType.APPLICATION_JSON) @@ -38,7 +39,8 @@ public PinCheckResponse pinCheck(PinCheckRequest request) { public PurchaseAuthResponse purchase(PurchaseAuthRequest request) { PurchaseAuthResponse response = new PurchaseAuthResponse(); - if (Optional.ofNullable((String) request.getPan()) + if (Optional.ofNullable(request.getPan()) + .map(Pan::getPan) .filter(s -> s.startsWith("42")) .isPresent()) { response.setResult(PurchaseAuthResponse.ResultEnum.OK); diff --git a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt index 9c5231f..16900a0 100644 --- a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt +++ b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt @@ -60,7 +60,6 @@ public class EmvTags { } - public void set84(String _84) { this._84 = _84; } @@ -86,7 +85,6 @@ public class EmvTags { } - public void set9F1A(String _9F1A) { this._9F1A = _9F1A; } diff --git a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt index 525c1a5..311dcc8 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt @@ -36,7 +36,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; public class PinCheckRequest { public static final String JSON_PROPERTY_PAN = "pan"; - private Object pan; + private ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan; public static final String JSON_PROPERTY_PIN_BLOCK = "pinBlock"; private String pinBlock; @@ -45,27 +45,26 @@ public class PinCheckRequest { private UUID uuid; - public PinCheckRequest pan(Object pan) { + public PinCheckRequest pan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; return this; } /** - * The number embossed on credit cards + * Get pan * @return pan **/ - @ApiModelProperty(required = true, value = "The number embossed on credit cards") + @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PAN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public Object getPan() { + public ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan getPan() { return pan; } - - public void setPan(Object pan) { + public void setPan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; } @@ -89,7 +88,6 @@ public class PinCheckRequest { } - public void setPinBlock(String pinBlock) { this.pinBlock = pinBlock; } @@ -114,7 +112,6 @@ public class PinCheckRequest { } - public void setUuid(UUID uuid) { this.uuid = uuid; } diff --git a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt index 9051eb8..81c5769 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt @@ -95,7 +95,6 @@ public class PinCheckResponse { } - public void setResult(ResultEnum result) { this.result = result; } @@ -121,7 +120,6 @@ public class PinCheckResponse { } - public void setTries(Integer tries) { this.tries = tries; } diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt index ca2e734..ccd2e01 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt @@ -40,7 +40,7 @@ public class PurchaseAuthRequest { private EmvTags emvTags; public static final String JSON_PROPERTY_PAN = "pan"; - private Object pan; + private ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan; public static final String JSON_PROPERTY_UUID = "uuid"; private UUID uuid; @@ -66,33 +66,31 @@ public class PurchaseAuthRequest { } - public void setEmvTags(EmvTags emvTags) { this.emvTags = emvTags; } - public PurchaseAuthRequest pan(Object pan) { + public PurchaseAuthRequest pan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; return this; } /** - * The number embossed on credit cards + * Get pan * @return pan **/ - @ApiModelProperty(required = true, value = "The number embossed on credit cards") + @ApiModelProperty(required = true, value = "") @JsonProperty(JSON_PROPERTY_PAN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public Object getPan() { + public ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan getPan() { return pan; } - - public void setPan(Object pan) { + public void setPan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; } @@ -116,7 +114,6 @@ public class PurchaseAuthRequest { } - public void setUuid(UUID uuid) { this.uuid = uuid; } diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt index b374769..72a2765 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt @@ -95,7 +95,6 @@ public class PurchaseAuthResponse { } - public void setApprovalCode(String approvalCode) { this.approvalCode = approvalCode; } @@ -121,7 +120,6 @@ public class PurchaseAuthResponse { } - public void setResult(ResultEnum result) { this.result = result; } From 3f4ab5c2f9d6b9fea64bac943f4197246a552767 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Sun, 6 Aug 2023 09:14:57 +0200 Subject: [PATCH 04/12] Remove OpenLiberty examples I don't have the time to keep them up to date --- .gitignore | 1 + README.adoc | 9 +- _idea/.idea/_idea.iml | 9 - _idea/.idea/compiler.xml | 4 +- _idea/.idea/encodings.xml | 10 +- _idea/.idea/misc.xml | 1 - ...ll_in_design_first_swagger_openliberty.xml | 14 - .../GenerationTest__swagger_openliberty_.xml | 20 - ...penliberty__clean_install_liberty_run_.xml | 29 -- ...iberty__install_liberty_run_w_o_tests_.xml | 29 -- ...irst_openapi_openliberty__liberty_dev_.xml | 27 -- ...irst_swagger_openliberty__liberty_dev_.xml | 29 -- code-first-openapi-openliberty/README.md | 20 - code-first-openapi-openliberty/pom.xml | 286 --------------- .../codefirst/rest/JaxrsApplication.java | 12 - .../codefirst/rest/JsonConfiguration.java | 18 - .../codefirst/rest/JsonContextResolver.java | 22 -- .../openapi/codefirst/rest/TxProc.java | 75 ---- .../codefirst/txproc/PinCheckRequest.java | 27 -- .../codefirst/txproc/PinCheckResponse.java | 24 -- .../codefirst/txproc/PurchaseAuthRequest.java | 28 -- .../txproc/PurchaseAuthResponse.java | 23 -- .../openapi/codefirst/txproc/doc/Model.java | 17 - .../codefirst/txproc/model/EmvTags.java | 25 -- .../openapi/codefirst/txproc/model/Pan.java | 40 -- .../txproc/model/PanJsonAdapter.java | 15 - .../src/main/liberty/config/server.xml | 20 - .../openapi/codefirst/OpenapiDocumentIT.java | 95 ----- .../codefirst/rest/TxProcPincheckIT.java | 27 -- .../codefirst/rest/TxProcPurchaseIT.java | 29 -- .../codefirst/txproc/PinCheckRequestTest.java | 37 -- .../txproc/PurchaseAuthRequestTest.java | 34 -- .../codefirst/txproc/model/EmvTagsTest.java | 29 -- .../codefirst/txproc/model/PanTest.java | 44 --- .../src/test/resources/openapi-sorted.yaml | 123 ------- .../src/test/resources/openapi.json | 176 --------- .../src/test/resources/openapi.yaml | 122 ------- .../src/test/resources/rest-api.http | 35 -- design-first-swagger-openliberty/README.md | 24 -- design-first-swagger-openliberty/pom.xml | 345 ------------------ .../designfirst/rest/JaxrsApplication.java | 8 - .../designfirst/rest/JsonConfiguration.java | 18 - .../designfirst/rest/JsonContextResolver.java | 22 -- .../swagger/designfirst/rest/TxProc.java | 54 --- .../swagger/designfirst/txproc/model/Pan.java | 39 -- .../txproc/model/PanJsonAdapter.java | 15 - .../src/main/liberty/config/server.xml | 20 - .../main/resources/.openapi-generator-ignore | 5 - .../META-INF/microprofile-config.properties | 2 - .../src/main/webapp/META-INF/openapi.yaml | 125 ------- .../designfirst/OpenapiDocumentIT.java | 94 ----- .../designfirst/generated/GenerationTest.java | 58 --- .../designfirst/rest/TxProcPincheckIT.java | 27 -- .../designfirst/rest/TxProcPurchaseIT.java | 29 -- .../designfirst/txproc/model/PanTest.java | 44 --- .../src/test/resources/.editorconfig | 2 - .../src/test/resources/EmvTags.java.txt | 111 ------ .../test/resources/PinCheckRequest.java.txt | 136 ------- .../test/resources/PinCheckResponse.java.txt | 142 ------- .../resources/PurchaseAuthRequest.java.txt | 137 ------- .../resources/PurchaseAuthResponse.java.txt | 142 ------- .../src/test/resources/openapi-sorted.yaml | 125 ------- .../src/test/resources/openapi.json | 179 --------- .../src/test/resources/openapi.yaml | 124 ------- .../src/test/resources/rest-api.http | 35 -- pom.xml | 2 - 66 files changed, 13 insertions(+), 3636 deletions(-) delete mode 100644 _idea/.idea/_idea.iml delete mode 100644 _idea/.idea/runConfigurations/All_in_design_first_swagger_openliberty.xml delete mode 100644 _idea/.idea/runConfigurations/GenerationTest__swagger_openliberty_.xml delete mode 100644 _idea/.idea/runConfigurations/code_first_openapi_openliberty__clean_install_liberty_run_.xml delete mode 100644 _idea/.idea/runConfigurations/code_first_openapi_openliberty__install_liberty_run_w_o_tests_.xml delete mode 100644 _idea/.idea/runConfigurations/code_first_openapi_openliberty__liberty_dev_.xml delete mode 100644 _idea/.idea/runConfigurations/design_first_swagger_openliberty__liberty_dev_.xml delete mode 100644 code-first-openapi-openliberty/README.md delete mode 100755 code-first-openapi-openliberty/pom.xml delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java delete mode 100644 code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java delete mode 100644 code-first-openapi-openliberty/src/main/liberty/config/server.xml delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequestTest.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequestTest.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java delete mode 100644 code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java delete mode 100644 code-first-openapi-openliberty/src/test/resources/openapi-sorted.yaml delete mode 100644 code-first-openapi-openliberty/src/test/resources/openapi.json delete mode 100644 code-first-openapi-openliberty/src/test/resources/openapi.yaml delete mode 100644 code-first-openapi-openliberty/src/test/resources/rest-api.http delete mode 100644 design-first-swagger-openliberty/README.md delete mode 100644 design-first-swagger-openliberty/pom.xml delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java delete mode 100644 design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java delete mode 100644 design-first-swagger-openliberty/src/main/liberty/config/server.xml delete mode 100644 design-first-swagger-openliberty/src/main/resources/.openapi-generator-ignore delete mode 100644 design-first-swagger-openliberty/src/main/webapp/META-INF/microprofile-config.properties delete mode 100644 design-first-swagger-openliberty/src/main/webapp/META-INF/openapi.yaml delete mode 100644 design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java delete mode 100644 design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/generated/GenerationTest.java delete mode 100644 design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java delete mode 100644 design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java delete mode 100644 design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java delete mode 100644 design-first-swagger-openliberty/src/test/resources/.editorconfig delete mode 100644 design-first-swagger-openliberty/src/test/resources/EmvTags.java.txt delete mode 100644 design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt delete mode 100644 design-first-swagger-openliberty/src/test/resources/PinCheckResponse.java.txt delete mode 100644 design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt delete mode 100644 design-first-swagger-openliberty/src/test/resources/PurchaseAuthResponse.java.txt delete mode 100644 design-first-swagger-openliberty/src/test/resources/openapi-sorted.yaml delete mode 100644 design-first-swagger-openliberty/src/test/resources/openapi.json delete mode 100644 design-first-swagger-openliberty/src/test/resources/openapi.yaml delete mode 100644 design-first-swagger-openliberty/src/test/resources/rest-api.http diff --git a/.gitignore b/.gitignore index dabc478..c6c98eb 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ tmp/ hs_err_pid* # IntelliJ IDEA +**/*.iml **/.idea/artifacts/ **/.idea/codeStyles/ **/.idea/dictionaries/ diff --git a/README.adoc b/README.adoc index fccd70c..f13f1b5 100644 --- a/README.adoc +++ b/README.adoc @@ -16,13 +16,12 @@ between the design-first and code-first approach. Accompanying presentation at https://www.eclipsecon.org/europe2019[eclipsecon Europe 2019] : https://www.eclipsecon.org/europe2019/sessions/microprofile-openapi-code-first-or-design-first[MicroProfile OpenAPI - code first or design first?] -The examples use https://quarkus.io/[Quarkus] and https://openliberty.io/[OpenLiberty] as servers -just because they not only support MicroProfile OpenAPI, but come also with an integrated UI. +The examples use https://quarkus.io/[Quarkus] as server +just because it not only support MicroProfile OpenAPI, but comes also with an integrated UI. But the examples should run with very few code changes in any MicroProfile compatible server. === Code First -* link:code-first-openapi-openliberty/README.md[code-first with OpenLiberty server and MicroProfile OpenAPI] * link:code-first-openapi-quarkus/README.md[code-first with Quarkus server and MicroProfile OpenAPI] * link:code-first-swagger/README.md[code-first with Swagger scanner running with Quarkus server] @@ -30,7 +29,6 @@ But the examples should run with very few code changes in any MicroProfile compa * link:design-first-openapi-generator/README.md[design-first with OpenAPI Generator and Quarkus server] * link:design-first-swagger-quarkus/README.md[design-first with Swagger Codegen and Quarkus server] -* link:design-first-swagger-openliberty/README.md[design-first with Swagger Codegen and OpenLiberty server] == Project Structure @@ -48,7 +46,7 @@ when the project dependencies are updated (like it happened when I updated from (the txt suffix protects them from being recognized as Java files by the IDE and being reformatted), allowing to compare the result of openapi-generator and swagger-codegen. -In addition all example projects have a `rest-api.http` file which allows to run some example HTTP +In addition, all example projects have a `rest-api.http` file which allows to run some example HTTP request against a running service directly from within IntelliJ. And there is an `_idea` directory containing the IntelliJ project setup. But you can import the projects easily in any IDE with Maven support. @@ -89,4 +87,3 @@ Code, Documentation and Annotations generated from the same information ** https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md[OpenAPI Specification (OpenAPI Initiative)] ** https://swagger.io/specification/[OpenAPI Specification (Swagger)] * https://quarkus.io/guides/openapi-swaggerui-guide[Quarkus - Using OpenAPI and Swagger UI] -* https://openliberty.io/guides/microprofile-openapi.html[OpenLiberty Guide - Documenting RESTful APIs] diff --git a/_idea/.idea/_idea.iml b/_idea/.idea/_idea.iml deleted file mode 100644 index d6ebd48..0000000 --- a/_idea/.idea/_idea.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/_idea/.idea/compiler.xml b/_idea/.idea/compiler.xml index 38f6db0..6d843b1 100644 --- a/_idea/.idea/compiler.xml +++ b/_idea/.idea/compiler.xml @@ -7,12 +7,10 @@ - + - - diff --git a/_idea/.idea/encodings.xml b/_idea/.idea/encodings.xml index 4d7edf6..cbbfe30 100644 --- a/_idea/.idea/encodings.xml +++ b/_idea/.idea/encodings.xml @@ -2,12 +2,18 @@ - + + + + - + + + + \ No newline at end of file diff --git a/_idea/.idea/misc.xml b/_idea/.idea/misc.xml index cce673c..1eb41e7 100644 --- a/_idea/.idea/misc.xml +++ b/_idea/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/_idea/.idea/runConfigurations/All_in_design_first_swagger_openliberty.xml b/_idea/.idea/runConfigurations/All_in_design_first_swagger_openliberty.xml deleted file mode 100644 index 083d795..0000000 --- a/_idea/.idea/runConfigurations/All_in_design_first_swagger_openliberty.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - \ No newline at end of file diff --git a/_idea/.idea/runConfigurations/GenerationTest__swagger_openliberty_.xml b/_idea/.idea/runConfigurations/GenerationTest__swagger_openliberty_.xml deleted file mode 100644 index f62a97a..0000000 --- a/_idea/.idea/runConfigurations/GenerationTest__swagger_openliberty_.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__clean_install_liberty_run_.xml b/_idea/.idea/runConfigurations/code_first_openapi_openliberty__clean_install_liberty_run_.xml deleted file mode 100644 index 43cb1d8..0000000 --- a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__clean_install_liberty_run_.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__install_liberty_run_w_o_tests_.xml b/_idea/.idea/runConfigurations/code_first_openapi_openliberty__install_liberty_run_w_o_tests_.xml deleted file mode 100644 index e578a63..0000000 --- a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__install_liberty_run_w_o_tests_.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__liberty_dev_.xml b/_idea/.idea/runConfigurations/code_first_openapi_openliberty__liberty_dev_.xml deleted file mode 100644 index e98e9ae..0000000 --- a/_idea/.idea/runConfigurations/code_first_openapi_openliberty__liberty_dev_.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/_idea/.idea/runConfigurations/design_first_swagger_openliberty__liberty_dev_.xml b/_idea/.idea/runConfigurations/design_first_swagger_openliberty__liberty_dev_.xml deleted file mode 100644 index 818ab3c..0000000 --- a/_idea/.idea/runConfigurations/design_first_swagger_openliberty__liberty_dev_.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/code-first-openapi-openliberty/README.md b/code-first-openapi-openliberty/README.md deleted file mode 100644 index 9cbf849..0000000 --- a/code-first-openapi-openliberty/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# OpenAPI code-first approach with OpenLiberty - -This directory contains a simple service implemented - -- using the *code-first* approach to provide an OpenAPI document -- running with [OpenLiberty](https://openliberty.io/)'s - MicroProfile [OpenAPI implementation](https://openliberty.io/guides/microprofile-openapi.html) - -For more information consult the [README](../README.adoc) in the parent directory. - -## How to run the service - -Using OpenLiberty's [dev mode](https://openliberty.io/blog/2019/10/17/dev-mode-developer-experience.html): - - mvn liberty:dev - -Once the service runs: - -- http://localhost:8080/openapi fetches the OpenAPI document -- http://localhost:8080/openapi/ui shows an interactive view of the API (based on Swagger-UI) diff --git a/code-first-openapi-openliberty/pom.xml b/code-first-openapi-openliberty/pom.xml deleted file mode 100755 index 2fdcc5f..0000000 --- a/code-first-openapi-openliberty/pom.xml +++ /dev/null @@ -1,286 +0,0 @@ - - - 4.0.0 - - ch.schlau.pesche.apidocs - code-first-openapi-openliberty - 0.9-SNAPSHOT - war - - apidocs.${project.artifactId} - - - UTF-8 - - - - 11 - - - 1.18.10 - 19.0.0.10 - - - 5.5.2 - 2.2 - 2.10.0 - 4.1.2 - 2.6 - 2.10.0 - 1.0.5 - 1.1.4 - - - 3.1 - 3.8.1 - 2.22.2 - 2.22.2 - 3.2.3 - - - 8080 - 8443 - - - - - - io.openliberty.features - features-bom - ${openliberty.version} - pom - import - - - - - - - - io.openliberty.features - jaxrs-2.1 - esa - provided - - - io.openliberty.features - jsonp-1.1 - esa - provided - - - io.openliberty.features - jsonb-1.0 - esa - provided - - - io.openliberty.features - cdi-2.0 - esa - provided - - - io.openliberty.features - beanValidation-2.0 - esa - provided - - - io.openliberty.features - mpConfig-1.3 - esa - provided - - - io.openliberty.features - mpOpenAPI-1.1 - esa - provided - - - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - - org.junit.jupiter - junit-jupiter - ${junit.jupiter.version} - test - - - org.hamcrest - hamcrest - ${hamcrest.version} - test - - - - org.glassfish - javax.json - ${glassfish.javax.json.version} - test - - - - org.eclipse - yasson - ${yasson.version} - test - - - io.rest-assured - rest-assured - ${restassured.version} - test - - - com.sun.xml.bind - jaxb-osgi - - - - - net.javacrumbs.json-unit - json-unit - ${json.unit.version} - test - - - commons-io - commons-io - ${commons-io.version} - test - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-2-version} - test - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson-2-version} - test - - - - - - - io.openliberty.tools - liberty-maven-plugin - ${liberty.plugin.version} - - - io.openliberty - openliberty-runtime - ${openliberty.version} - zip - - usr - - ${liberty.http.port} - ${liberty.https.port} - - - - - install-liberty - prepare-package - - install-server - - - - create-default-server - prepare-package - - create - - - - install-app - package - - deploy - - - apps - true - - - - start-server - pre-integration-test - - test-start - - - - stop-server - post-integration-test - - test-stop - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - - ${java.release} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven.failsafe.plugin.version} - - - integration-test - integration-test - - integration-test - - - - ${liberty.http.port} - - - - - verify-results - - verify - - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven.war.plugin.version} - - false - - - - - diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java deleted file mode 100644 index a611465..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; -import org.eclipse.microprofile.openapi.annotations.info.Info; - -@OpenAPIDefinition(info = @Info(title = "txproc-code-first-openapi", version = "0.9")) -@ApplicationPath("/api") -public class JaxrsApplication extends Application { -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java deleted file mode 100644 index 8920fd5..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java +++ /dev/null @@ -1,18 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.PanJsonAdapter; -import lombok.experimental.UtilityClass; - -@UtilityClass -public class JsonConfiguration { - - public static final JsonbConfig JSON_CONFIG = new JsonbConfig() - .withAdapters(new PanJsonAdapter()) - ; - - public static final Jsonb JSONB = JsonbBuilder.create(JSON_CONFIG); -} \ No newline at end of file diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java deleted file mode 100644 index f0b6307..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java +++ /dev/null @@ -1,22 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; - -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; - -@Provider -public class JsonContextResolver implements ContextResolver { - - private final Jsonb jsonb; - - public JsonContextResolver() { - jsonb = JSONB; - } - - @Override - public Jsonb getContext(Class type) { - return jsonb; - } -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java deleted file mode 100644 index 97582d4..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java +++ /dev/null @@ -1,75 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import java.util.Optional; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.eclipse.microprofile.openapi.annotations.Operation; -import org.eclipse.microprofile.openapi.annotations.media.Content; -import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody; -import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.PinCheckRequest; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.PinCheckResponse; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.PurchaseAuthRequest; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.PurchaseAuthResponse; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.EmvTags; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.Pan; - -@Path("/txproc") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class TxProc { - - @Path("/pincheck") - @POST - @Operation(summary = "Check the pin") - @APIResponse(description = "PIN Check Response", - content = @Content(schema = @Schema(implementation = PinCheckResponse.class))) - public PinCheckResponse pinCheck( - @RequestBody(description = "PIN Check Request Body", - content = @Content(schema = @Schema(implementation = PinCheckRequest.class)), - required = true - ) PinCheckRequest request) { - - PinCheckResponse response = new PinCheckResponse(); - if ("magic".equals(request.getPinBlock())) { - response.setResult(PinCheckResponse.Code.OK); - response.setTries(3); - } else { - response.setResult(PinCheckResponse.Code.WRONG); - } - return response; - } - - @Path("/purchase") - @POST - @Operation(summary = "Authorize a Purchase") - @APIResponse(description = "Purchase Response", - content = @Content(schema = @Schema(implementation = PurchaseAuthResponse.class))) - public PurchaseAuthResponse purchase( - @RequestBody(description = "Purchase Request Body", - content = @Content(schema = @Schema(implementation = PurchaseAuthRequest.class)), - required = true - ) PurchaseAuthRequest request) { - - PurchaseAuthResponse response = new PurchaseAuthResponse(); - if (Optional.ofNullable(request.getPan()) - .map(Pan::getPan) - .filter(s -> s.startsWith("42")) - .isPresent()) { - response.setResult(PurchaseAuthResponse.Code.OK); - response.setApprovalCode("OK42." + - Optional.ofNullable(request.getEmvTags()).map(EmvTags::getX9F1A).orElse("756")); - } else { - response.setResult(PurchaseAuthResponse.Code.WRONG); - } - return response; - } - -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java deleted file mode 100644 index bf3e8c5..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java +++ /dev/null @@ -1,27 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import java.util.UUID; - -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.doc.Model; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.Pan; -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "Request for checking a PIN", - requiredProperties = {"uuid", "pan", "pinBlock"}) -@Getter -@Setter -public class PinCheckRequest { - - @Schema(type = SchemaType.STRING, description = Model.UUID) - private UUID uuid; - - // the class Pan already carries a @Schema annotation - private Pan pan; - - @Schema(description = Model.PIN_BLOCK) - private String pinBlock; -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java deleted file mode 100644 index d06d02d..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "Tells if the PIN in the request was correct") -@Getter -@Setter -public class PinCheckResponse { - - // can't put @Schema annotation on the enum for OpenLiberty - public enum Code { - OK, - WRONG - } - - @Schema(description = "Result of the request") - private Code result; - - @Schema(description = "Number of remaining tries") - private int tries; -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java deleted file mode 100644 index 1c03c05..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import java.util.UUID; - -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.doc.Model; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.EmvTags; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.Pan; -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "Request for authorizing a Purchase", - requiredProperties = {"uuid", "pan"}) -@Getter -@Setter -public class PurchaseAuthRequest { - - @Schema(type = SchemaType.STRING, description = Model.UUID) - private UUID uuid; - - // the class Pan already carries a @Schema annotation - private Pan pan; - - // the class EmvTags already carries a @Schema annotation - private EmvTags emvTags; -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java deleted file mode 100644 index 0ae23bf..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import lombok.Getter; -import lombok.Setter; - -@Schema(description = "Response to PurchaseAuthRequest") -@Getter -@Setter -public class PurchaseAuthResponse { - - public enum Code { - OK, - WRONG - } - - @Schema(description = "Result of the request") - private Code result; - - @Schema(description = "Code referencing the successful authorization") - private String approvalCode; -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java deleted file mode 100644 index 5d2c498..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java +++ /dev/null @@ -1,17 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.doc; - -import lombok.experimental.UtilityClass; - -/** - * Centralized strings for use with [org.eclipse.microprofile.openapi.annotations.media.Schema] - * annotations - */ -@UtilityClass -public class Model { - - public static final String UUID = "Unique ID of the request"; - - public static final String PIN_BLOCK = "Encrypted binary data containing a PIN" - + "\n\nFieldcode: C003"; - -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java deleted file mode 100644 index 6dd9b2d..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java +++ /dev/null @@ -1,25 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; - -import javax.json.bind.annotation.JsonbProperty; - -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import lombok.Getter; -import lombok.Setter; - -/** - * In the real world this would probably be a Map of enum with all the known tags - */ -@Schema(title = "EmvTags", description = "Collection of EMV tags") -@Getter -@Setter -public class EmvTags { - - @JsonbProperty("84") - @Schema(name = "84", title = "Dedicated Filename", description = "The EMV AID as reported by ICC") - private String x84; - - // no `@JsonbProperty("9F1A")` to observe if the openapi scanner considers the `name` - @Schema(name = "9F1A", description = "Terminal Country Code") - private String x9F1A; -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java deleted file mode 100644 index ba241d9..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java +++ /dev/null @@ -1,40 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; - -import javax.validation.constraints.Pattern; - -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; -import org.eclipse.microprofile.openapi.annotations.media.Schema; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Schema(title = "PAN (Primary Account Number)", - description = "The number embossed on credit cards", - type = SchemaType.STRING) -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class Pan { - - @Pattern(regexp = "[0-9]{12,19}") - private String pan; - - /** - * For data protection reasons (PCI-DSS compliance) the complete PAN must not - * be shown unless absolutely needed. This method masks out the middle digits - * of the PAN, allowing the result to be safely displayed (e.g. on receipts) - * - * @return PAN with the middle digits safely replaced by 'x' characters - */ - public String asMaskedPan() { - if (pan != null && pan.length() >= 12 && pan.length() <= 19) { - int lastPos = pan.length() - 4; - return new StringBuilder(pan).replace(6, lastPos, "xxxxxxxxxxxxxxxxxxx".substring(0, lastPos - 6)).toString(); - } else { - return pan; - } - } -} diff --git a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java b/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java deleted file mode 100644 index 9852212..0000000 --- a/code-first-openapi-openliberty/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java +++ /dev/null @@ -1,15 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; - -import javax.json.bind.adapter.JsonbAdapter; - -public class PanJsonAdapter implements JsonbAdapter { - @Override - public String adaptToJson(Pan pan) throws Exception { - return pan.getPan(); - } - - @Override - public Pan adaptFromJson(String s) throws Exception { - return new Pan(s); - } -} diff --git a/code-first-openapi-openliberty/src/main/liberty/config/server.xml b/code-first-openapi-openliberty/src/main/liberty/config/server.xml deleted file mode 100644 index 5296b40..0000000 --- a/code-first-openapi-openliberty/src/main/liberty/config/server.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - jaxrs-2.1 - jsonp-1.1 - jsonb-1.0 - cdi-2.0 - beanValidation-2.0 - mpConfig-1.3 - mpOpenAPI-1.1 - - - - - - - - - diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java deleted file mode 100644 index 6e31261..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java +++ /dev/null @@ -1,95 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst; - -import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.MINIMIZE_QUOTES; -import static io.restassured.RestAssured.given; -import static io.restassured.RestAssured.when; -import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import javax.ws.rs.core.MediaType; - -import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; - -import lombok.Getter; -import lombok.Setter; - -class OpenapiDocumentIT { - - @Getter - @Setter - static class OpenapiSkeleton { - String openapi; - Object info; - Object servers; - Object paths; - Object components; - Object security; - Object tags; - Object externalDocs; - } - - @Test - void openapi_yaml() throws IOException { - - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); - - String document = when().get("/openapi") - .then() - .statusCode(200) - .extract().response().asString(); - - String yamlSorted = sortYaml(document); - - assertAll("openapi yaml" - // the unsorted document with OpenLiberty has no deterministic order - // , () -> assertThat("unsorted", document, is(expected)) - , () -> assertThat("sorted", yamlSorted, is(expectedSorted)) - ); - } - - @Test - void openapi_json() throws IOException { - - String expected = loadResourceFile("openapi.json"); - - String document = given().accept(MediaType.APPLICATION_JSON) - .when().get("/openapi") - .then() - .statusCode(200) - .assertThat().contentType(MediaType.APPLICATION_JSON) - .extract().response().asString(); - - assertThat(document, jsonEquals(expected)); - } - - private String sortYaml(String yaml) throws IOException { - ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory().enable(MINIMIZE_QUOTES)); - OpenapiSkeleton objFromYaml = yamlMapper.readValue(yaml, OpenapiSkeleton.class); - - ObjectMapper jsonMapper = new ObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) - .configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); - String jsonSorted = jsonMapper.writeValueAsString(objFromYaml); - Object objFromJson = jsonMapper.readValue(jsonSorted, Object.class); - - return yamlMapper.writeValueAsString(objFromJson); - } - - private String loadResourceFile(String s) throws IOException { - return IOUtils.toString(getClass().getClassLoader().getResourceAsStream(s), StandardCharsets.UTF_8) - // needed on Windows depending on the Git configuration (core.autocrlf) - .replace("\r\n", "\n"); - } -} diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java deleted file mode 100644 index fc271f3..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java +++ /dev/null @@ -1,27 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; - -import javax.ws.rs.core.MediaType; - -import org.junit.jupiter.api.Test; - -class TxProcPincheckIT { - - @Test - void pincheck_ok() { - // @formatter:off - given() - .header("Content-Type", MediaType.APPLICATION_JSON) - .body("{\"uuid\": \"aaaaaaaa-bbbb-cccc-dddd-012345678901\", \"pinBlock\": \"magic\"}") - .when() - .post("/api/txproc/pincheck") - .then() - .statusCode(200) - .body("result", is("OK")) - .body("tries", is(3)) - ; - // @formatter:off - } -} diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java deleted file mode 100644 index 417d034..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java +++ /dev/null @@ -1,29 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.rest; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; - -import javax.ws.rs.core.MediaType; - -import org.junit.jupiter.api.Test; - -class TxProcPurchaseIT { - - @Test - void purchase_ok() { - // @formatter:off - given() - .header("Content-Type", MediaType.APPLICATION_JSON) - .body("{\"uuid\": \"aaaaaaaa-bbbb-cccc-dddd-012345678901\"," - +" \"pan\": \"4244333322221111\"," - +" \"emvTags\": { \"84\": \"A0000000041010\", \"x9F1A\": \"250\" } }") - .when() - .post("/api/txproc/purchase") - .then() - .statusCode(200) - .body("result", is("OK")) - .body("approvalCode", is("OK42.250")) - ; - // @formatter:off - } -} \ No newline at end of file diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequestTest.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequestTest.java deleted file mode 100644 index 559a087..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequestTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.util.UUID; - -import org.junit.jupiter.api.Test; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.Pan; - -class PinCheckRequestTest { - - @Test - void json_roundtrip() { - - PinCheckRequest request = new PinCheckRequest(); - request.setUuid(UUID.fromString("abcdabcd-1234-5678-aaaa-cccccccccccc")); - - // JSON serialization - String jsonString1 = JSONB.toJson(request); - assertThat(jsonString1, is("{\"uuid\":\"abcdabcd-1234-5678-aaaa-cccccccccccc\"}")); - - // set the other properties as well - request.setPan(new Pan("111222333444")); - request.setPinBlock("-secret-"); - String jsonString2 = JSONB.toJson(request); - assertThat(jsonString2, is("{\"pan\":\"111222333444\",\"pinBlock\":\"-secret-\",\"uuid\":\"abcdabcd-1234-5678-aaaa-cccccccccccc\"}")); - - // JSON deserialization - PinCheckRequest roundtrip = JSONB.fromJson(jsonString2, PinCheckRequest.class); - assertThat(roundtrip.getUuid().toString(), is("abcdabcd-1234-5678-aaaa-cccccccccccc")); - assertThat(roundtrip.getPan().getPan(), is("111222333444")); - assertThat(roundtrip.getPinBlock(), is("-secret-")); - } -} diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequestTest.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequestTest.java deleted file mode 100644 index fc448af..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequestTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc; - -import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.util.UUID; - -import org.junit.jupiter.api.Test; - -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.EmvTags; -import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.Pan; - -class PurchaseAuthRequestTest { - - @Test - void json_roundtrip() { - - PurchaseAuthRequest request = new PurchaseAuthRequest(); - request.setUuid(UUID.fromString("abcdabcd-1234-5678-aaaa-cccccccccccc")); - request.setPan(new Pan("42")); - var emvTags = new EmvTags(); - emvTags.setX84("A0000000041010"); - request.setEmvTags(emvTags); - - // JSON serialization - String jsonString = JSONB.toJson(request); - assertThat(jsonString, is("{\"emvTags\":{\"84\":\"A0000000041010\"},\"pan\":\"42\",\"uuid\":\"abcdabcd-1234-5678-aaaa-cccccccccccc\"}")); - - // JSON deserialization - PurchaseAuthRequest roundtrip = JSONB.fromJson(jsonString, PurchaseAuthRequest.class); - assertThat(roundtrip.getUuid().toString(), is("abcdabcd-1234-5678-aaaa-cccccccccccc")); - } -} \ No newline at end of file diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java deleted file mode 100644 index 1fb8daa..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; - -import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import javax.json.bind.Jsonb; - -import org.junit.jupiter.api.Test; - -class EmvTagsTest { - - @Test - void json_roundtrip() { - - Jsonb jsonb = JSONB; - - EmvTags emv = new EmvTags(); - emv.setX84("A0000000043060"); - - // JSON serialization - String jsonString = jsonb.toJson(emv); - assertThat(jsonString, is("{\"84\":\"A0000000043060\"}")); - - // JSON deserialization - EmvTags roundtrip = jsonb.fromJson(jsonString, EmvTags.class); - assertThat(roundtrip.getX84(), is("A0000000043060")); - } -} \ No newline at end of file diff --git a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java b/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java deleted file mode 100644 index 4602499..0000000 --- a/code-first-openapi-openliberty/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; - -import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; - -import javax.json.bind.Jsonb; - -import org.junit.jupiter.api.Test; - -class PanTest { - - @Test - void asMaskedPan_valid() { - - assertThat(new Pan("123456789012").asMaskedPan(), is("123456xx9012")); - assertThat(new Pan("1234567890123456789").asMaskedPan(), is("123456xxxxxxxxx6789")); - } - - @Test - void asMaskedPan_invalid() { - - assertThat(new Pan(null).asMaskedPan(), is(nullValue())); - assertThat(new Pan("1234567890").asMaskedPan(), is("1234567890")); - assertThat(new Pan("12345678901234567890").asMaskedPan(), is("12345678901234567890")); - } - - @Test - void json_roundtrip() { - - Jsonb jsonb = JSONB; - - Pan pan = new Pan("4444333322221111"); - - // JSON serialization - String jsonString = jsonb.toJson(pan); - assertThat(jsonString, is("\"4444333322221111\"")); - - // JSON deserialization - Pan roundtrip = jsonb.fromJson(jsonString, Pan.class); - assertThat(roundtrip.getPan(), is("4444333322221111")); - } -} \ No newline at end of file diff --git a/code-first-openapi-openliberty/src/test/resources/openapi-sorted.yaml b/code-first-openapi-openliberty/src/test/resources/openapi-sorted.yaml deleted file mode 100644 index accdce7..0000000 --- a/code-first-openapi-openliberty/src/test/resources/openapi-sorted.yaml +++ /dev/null @@ -1,123 +0,0 @@ ---- -openapi: 3.0.0 -info: - title: txproc-code-first-openapi - version: 0.9 -servers: -- url: http://localhost:8080 -paths: - /api/txproc/pincheck: - post: - operationId: pinCheck - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckRequest' - description: PIN Check Request Body - required: true - responses: - default: - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckResponse' - description: PIN Check Response - summary: Check the pin - /api/txproc/purchase: - post: - operationId: purchase - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthRequest' - description: Purchase Request Body - required: true - responses: - default: - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthResponse' - description: Purchase Response - summary: Authorize a Purchase -components: - schemas: - EmvTags: - description: Collection of EMV tags - properties: - "84": - description: The EMV AID as reported by ICC - title: Dedicated Filename - type: string - "9F1A": - description: Terminal Country Code - type: string - title: EmvTags - type: object - PinCheckRequest: - description: Request for checking a PIN - properties: - pan: - description: The number embossed on credit cards - title: PAN (Primary Account Number) - type: string - pinBlock: - description: |- - Encrypted binary data containing a PIN - - Fieldcode: C003 - type: string - uuid: - description: Unique ID of the request - format: uuid - type: string - required: - - pan - - pinBlock - - uuid - type: object - PinCheckResponse: - description: Tells if the PIN in the request was correct - properties: - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - tries: - description: Number of remaining tries - type: integer - type: object - PurchaseAuthRequest: - description: Request for authorizing a Purchase - properties: - emvTags: - $ref: '#/components/schemas/EmvTags' - pan: - description: The number embossed on credit cards - title: PAN (Primary Account Number) - type: string - uuid: - description: Unique ID of the request - format: uuid - type: string - required: - - pan - - uuid - type: object - PurchaseAuthResponse: - description: Response to PurchaseAuthRequest - properties: - approvalCode: - description: Code referencing the successful authorization - type: string - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - type: object diff --git a/code-first-openapi-openliberty/src/test/resources/openapi.json b/code-first-openapi-openliberty/src/test/resources/openapi.json deleted file mode 100644 index a2a2321..0000000 --- a/code-first-openapi-openliberty/src/test/resources/openapi.json +++ /dev/null @@ -1,176 +0,0 @@ -{ - "components": { - "schemas": { - "EmvTags": { - "description": "Collection of EMV tags", - "properties": { - "84": { - "description": "The EMV AID as reported by ICC", - "title": "Dedicated Filename", - "type": "string" - }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" - } - }, - "title": "EmvTags", - "type": "object" - }, - "PinCheckRequest": { - "description": "Request for checking a PIN", - "properties": { - "pan": { - "description": "The number embossed on credit cards", - "title": "PAN (Primary Account Number)", - "type": "string" - }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" - }, - "uuid": { - "description": "Unique ID of the request", - "format": "uuid", - "type": "string" - } - }, - "required": [ - "pan", - "pinBlock", - "uuid" - ], - "type": "object" - }, - "PinCheckResponse": { - "description": "Tells if the PIN in the request was correct", - "properties": { - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" - }, - "tries": { - "description": "Number of remaining tries", - "type": "integer" - } - }, - "type": "object" - }, - "PurchaseAuthRequest": { - "description": "Request for authorizing a Purchase", - "properties": { - "emvTags": { - "$ref": "#/components/schemas/EmvTags" - }, - "pan": { - "description": "The number embossed on credit cards", - "title": "PAN (Primary Account Number)", - "type": "string" - }, - "uuid": { - "description": "Unique ID of the request", - "format": "uuid", - "type": "string" - } - }, - "required": [ - "pan", - "uuid" - ], - "type": "object" - }, - "PurchaseAuthResponse": { - "description": "Response to PurchaseAuthRequest", - "properties": { - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" - }, - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" - } - }, - "type": "object" - } - } - }, - "info": { - "title": "txproc-code-first-openapi", - "version": "0.9" - }, - "openapi": "3.0.0", - "paths": { - "/api/txproc/pincheck": { - "post": { - "operationId": "pinCheck", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" - } - } - }, - "description": "PIN Check Request Body", - "required": true - }, - "responses": { - "default": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" - } - } - }, - "description": "PIN Check Response" - } - }, - "summary": "Check the pin" - } - }, - "/api/txproc/purchase": { - "post": { - "operationId": "purchase", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" - } - } - }, - "description": "Purchase Request Body", - "required": true - }, - "responses": { - "default": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" - } - } - }, - "description": "Purchase Response" - } - }, - "summary": "Authorize a Purchase" - } - } - }, - "servers": [ - { - "url": "http://localhost:8080" - } - ] -} diff --git a/code-first-openapi-openliberty/src/test/resources/openapi.yaml b/code-first-openapi-openliberty/src/test/resources/openapi.yaml deleted file mode 100644 index 00f3fd0..0000000 --- a/code-first-openapi-openliberty/src/test/resources/openapi.yaml +++ /dev/null @@ -1,122 +0,0 @@ -openapi: 3.0.0 -info: - title: txproc-code-first-openapi - version: "0.9" -servers: -- url: http://localhost:8080 -paths: - /api/txproc/pincheck: - post: - summary: Check the pin - operationId: pinCheck - requestBody: - description: PIN Check Request Body - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckRequest' - required: true - responses: - default: - description: PIN Check Response - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckResponse' - /api/txproc/purchase: - post: - summary: Authorize a Purchase - operationId: purchase - requestBody: - description: Purchase Request Body - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthRequest' - required: true - responses: - default: - description: Purchase Response - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthResponse' -components: - schemas: - PurchaseAuthResponse: - type: object - properties: - result: - type: string - description: Result of the request - enum: - - OK - - WRONG - approvalCode: - type: string - description: Code referencing the successful authorization - description: Response to PurchaseAuthRequest - EmvTags: - title: EmvTags - type: object - properties: - 84: - title: Dedicated Filename - type: string - description: The EMV AID as reported by ICC - 9F1A: - type: string - description: Terminal Country Code - description: Collection of EMV tags - PinCheckResponse: - type: object - properties: - result: - type: string - description: Result of the request - enum: - - OK - - WRONG - tries: - type: integer - description: Number of remaining tries - description: Tells if the PIN in the request was correct - PurchaseAuthRequest: - required: - - pan - - uuid - type: object - properties: - uuid: - type: string - description: Unique ID of the request - format: uuid - pan: - title: PAN (Primary Account Number) - type: string - description: The number embossed on credit cards - emvTags: - $ref: '#/components/schemas/EmvTags' - description: Request for authorizing a Purchase - PinCheckRequest: - required: - - pan - - pinBlock - - uuid - type: object - properties: - uuid: - type: string - description: Unique ID of the request - format: uuid - pan: - title: PAN (Primary Account Number) - type: string - description: The number embossed on credit cards - pinBlock: - type: string - description: |- - Encrypted binary data containing a PIN - - Fieldcode: C003 - description: Request for checking a PIN diff --git a/code-first-openapi-openliberty/src/test/resources/rest-api.http b/code-first-openapi-openliberty/src/test/resources/rest-api.http deleted file mode 100644 index 78acf50..0000000 --- a/code-first-openapi-openliberty/src/test/resources/rest-api.http +++ /dev/null @@ -1,35 +0,0 @@ -# Swagger/OpenAPI in YAML format -GET http://localhost:8080/openapi - -### - -# Swagger/OpenAPI in JSON format -GET http://localhost:8080/openapi -Accept: application/json - -### - -POST http://localhost:8080/api/txproc/pincheck -Content-Type: application/json - -{ - "uuid": "aaaaaaaa-bbbb-cccc-dddd-012345678901", - "pan" : "100000000042", - "pinBlock": "magic" -} - -### - -POST http://localhost:8080/api/txproc/purchase -Content-Type: application/json - -{ - "uuid": "aaaaaaaa-bbbb-cccc-dddd-012345678901", - "pan": "4244333322221111", - "emvTags": { - "84" : "A0000000041010", - "x9F1A" : "250" - } -} - -### diff --git a/design-first-swagger-openliberty/README.md b/design-first-swagger-openliberty/README.md deleted file mode 100644 index 78dac8b..0000000 --- a/design-first-swagger-openliberty/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# OpenAPI design-first approach with OpenLiberty server and Swagger Codegen - -This directory contains a simple service implemented - -- using the *design-first* approach to provide an OpenAPI document -- running with [OpenLiberty](https://openliberty.io/) server (providing the - MicroProfile [OpenAPI](https://openliberty.io/guides/microprofile-openapi.html) - endpoints), serving the static hand-written OpenAPI document that - is also used to generate the POJOs of the service interface -- the POJOs are generated using [Swagger Codegen](https://swagger.io/tools/swagger-codegen/)'s - Maven [plugin](https://github.com/swagger-api/swagger-codegen/tree/3.0.0/modules/swagger-codegen-maven-plugin) - -For more information consult the [README](../README.adoc) in the parent directory. - -## How to run the service - -Using OpenLiberty's [dev mode](https://openliberty.io/blog/2019/10/17/dev-mode-developer-experience.html): - - mvn liberty:dev - -Once the service runs: - -- http://localhost:8080/openapi fetches the OpenAPI document -- http://localhost:8080/openapi/ui shows an interactive view of the API (based on Swagger-UI) diff --git a/design-first-swagger-openliberty/pom.xml b/design-first-swagger-openliberty/pom.xml deleted file mode 100644 index eed1e05..0000000 --- a/design-first-swagger-openliberty/pom.xml +++ /dev/null @@ -1,345 +0,0 @@ - - - 4.0.0 - - ch.schlau.pesche.apidocs - design-first-swagger-openliberty - 0.9-SNAPSHOT - war - - apidocs.${project.artifactId} - - - UTF-8 - - - - 11 - - - 2.10.0 - 1.18.10 - 19.0.0.10 - 2.1.2 - 3.0.20 - - - 5.5.2 - 2.2 - 2.10.0 - 4.1.2 - 2.6 - 1.0.5 - 1.1.4 - - - 3.1 - 3.8.1 - 2.22.2 - 2.22.2 - 3.2.3 - - ${project.build.directory}/generated-sources/swagger - - - 8080 - 8443 - - - - - - io.openliberty.features - features-bom - ${openliberty.version} - pom - import - - - - - - - - io.openliberty.features - jaxrs-2.1 - esa - provided - - - io.openliberty.features - jsonp-1.1 - esa - provided - - - io.openliberty.features - jsonb-1.0 - esa - provided - - - io.openliberty.features - cdi-2.0 - esa - provided - - - io.openliberty.features - beanValidation-2.0 - esa - provided - - - io.openliberty.features - mpConfig-1.3 - esa - provided - - - io.openliberty.features - mpOpenAPI-1.1 - esa - provided - - - - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson-2-version} - provided - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-2-version} - provided - - - io.swagger.core.v3 - swagger-annotations - ${swagger.version} - - - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - - org.junit.jupiter - junit-jupiter - ${junit.jupiter.version} - test - - - org.hamcrest - hamcrest - ${hamcrest.version} - test - - - - org.glassfish - javax.json - ${glassfish.javax.json.version} - test - - - - org.eclipse - yasson - ${yasson.version} - test - - - io.rest-assured - rest-assured - ${restassured.version} - test - - - com.sun.xml.bind - jaxb-osgi - - - - - net.javacrumbs.json-unit - json-unit - ${json.unit.version} - test - - - commons-io - commons-io - ${commons-io.version} - test - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson-2-version} - test - - - - - - - io.swagger.codegen.v3 - swagger-codegen-maven-plugin - ${swagger.codegen.version} - - - - generate - - - ${project.basedir}/src/main/webapp/META-INF/openapi.yaml - java - false - false - false - ${project.basedir}/src/main/resources/.openapi-generator-ignore - - - true - java8 - resteasy - false - . - ch.schlau.pesche.apidocs.swagger.designfirst.generated.model - - - - hideGenerationTimestamp=true - - - Pan=ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan - - - - - - - io.openliberty.tools - liberty-maven-plugin - ${liberty.plugin.version} - - - io.openliberty - openliberty-runtime - ${openliberty.version} - zip - - usr - - ${liberty.http.port} - ${liberty.https.port} - - - - - install-liberty - prepare-package - - install-server - - - - create-default-server - prepare-package - - create - - - - install-app - package - - deploy - - - apps - true - - - - start-server - pre-integration-test - - test-start - - - - stop-server - post-integration-test - - test-stop - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven.compiler.plugin.version} - - - ${java.release} - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven.surefire.plugin.version} - - - ${generated.path} - - - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven.failsafe.plugin.version} - - - integration-test - integration-test - - integration-test - - - - ${liberty.http.port} - - - - - verify-results - - verify - - - - - - org.apache.maven.plugins - maven-war-plugin - ${maven.war.plugin.version} - - false - - - - - diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java deleted file mode 100644 index cffd174..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java +++ /dev/null @@ -1,8 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -@ApplicationPath("/api") -public class JaxrsApplication extends Application { -} diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java deleted file mode 100644 index 4a1acc5..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java +++ /dev/null @@ -1,18 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; - -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.PanJsonAdapter; -import lombok.experimental.UtilityClass; - -@UtilityClass -public class JsonConfiguration { - - public static final JsonbConfig JSON_CONFIG = new JsonbConfig() - .withAdapters(new PanJsonAdapter()) - ; - - public static final Jsonb JSONB = JsonbBuilder.create(JSON_CONFIG); -} \ No newline at end of file diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java deleted file mode 100644 index fc3df3f..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java +++ /dev/null @@ -1,22 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import static ch.schlau.pesche.apidocs.swagger.designfirst.rest.JsonConfiguration.JSONB; - -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; - -@Provider -public class JsonContextResolver implements ContextResolver { - - private final Jsonb jsonb; - - public JsonContextResolver() { - jsonb = JSONB; - } - - @Override - public Jsonb getContext(Class type) { - return jsonb; - } -} diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java deleted file mode 100644 index 828df91..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java +++ /dev/null @@ -1,54 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import java.util.Optional; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PinCheckRequest; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PinCheckResponse; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PurchaseAuthRequest; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PurchaseAuthResponse; -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; - -@Path("/txproc") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -public class TxProc { - - @Path("/pincheck") - @POST - public PinCheckResponse pinCheck(PinCheckRequest request) { - - PinCheckResponse response = new PinCheckResponse(); - if ("magic".equals(request.getPinBlock())) { - response.setResult(PinCheckResponse.ResultEnum.OK); - response.setTries(3); - } else { - response.setResult(PinCheckResponse.ResultEnum.WRONG); - } - return response; - } - - @Path("/purchase") - @POST - public PurchaseAuthResponse purchase(PurchaseAuthRequest request) { - - PurchaseAuthResponse response = new PurchaseAuthResponse(); - if (Optional.ofNullable(request.getPan()) - .map(Pan::getPan) - .filter(s -> s.startsWith("42")) - .isPresent()) { - response.setResult(PurchaseAuthResponse.ResultEnum.OK); - response.setApprovalCode("OK42." + - Optional.ofNullable(request.getEmvTags()).map(EmvTags::get9f1A).orElse("756")); - } else { - response.setResult(PurchaseAuthResponse.ResultEnum.WRONG); - } - return response; - } -} diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java deleted file mode 100644 index 40637b4..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java +++ /dev/null @@ -1,39 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model; - -import javax.validation.constraints.Pattern; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * PAN (Primary Account Number) - * - * The number embossed on credit cards - */ -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -public class Pan { - - @Pattern(regexp = "[0-9]{12,19}") - private String pan; - - /** - * For data protection reasons (PCI-DSS compliance) the complete PAN must not - * be shown unless absolutely needed. This method masks out the middle digits - * of the PAN, allowing the result to be safely displayed (e.g. on receipts) - * - * @return PAN with the middle digits safely replaced by 'x' characters - */ - public String asMaskedPan() { - if (pan != null && pan.length() >= 12 && pan.length() <= 19) { - int lastPos = pan.length() - 4; - return new StringBuilder(pan).replace(6, lastPos, "xxxxxxxxxxxxxxxxxxx".substring(0, lastPos - 6)).toString(); - } else { - return pan; - } - } -} diff --git a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java b/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java deleted file mode 100644 index 14f9c51..0000000 --- a/design-first-swagger-openliberty/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java +++ /dev/null @@ -1,15 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model; - -import javax.json.bind.adapter.JsonbAdapter; - -public class PanJsonAdapter implements JsonbAdapter { - @Override - public String adaptToJson(Pan pan) throws Exception { - return pan.getPan(); - } - - @Override - public Pan adaptFromJson(String s) throws Exception { - return new Pan(s); - } -} diff --git a/design-first-swagger-openliberty/src/main/liberty/config/server.xml b/design-first-swagger-openliberty/src/main/liberty/config/server.xml deleted file mode 100644 index d0c603a..0000000 --- a/design-first-swagger-openliberty/src/main/liberty/config/server.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - jaxrs-2.1 - jsonp-1.1 - jsonb-1.0 - cdi-2.0 - beanValidation-2.0 - mpConfig-1.3 - mpOpenAPI-1.1 - - - - - - - - - diff --git a/design-first-swagger-openliberty/src/main/resources/.openapi-generator-ignore b/design-first-swagger-openliberty/src/main/resources/.openapi-generator-ignore deleted file mode 100644 index 2a27b92..0000000 --- a/design-first-swagger-openliberty/src/main/resources/.openapi-generator-ignore +++ /dev/null @@ -1,5 +0,0 @@ -# file similar to `.gitignore` (using the same syntax) -# with file patterns that should not be generated by the code generation plugin -# -# this file is empty and serves just to suppress this warning: -# "Output directory does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated." \ No newline at end of file diff --git a/design-first-swagger-openliberty/src/main/webapp/META-INF/microprofile-config.properties b/design-first-swagger-openliberty/src/main/webapp/META-INF/microprofile-config.properties deleted file mode 100644 index ac79149..0000000 --- a/design-first-swagger-openliberty/src/main/webapp/META-INF/microprofile-config.properties +++ /dev/null @@ -1,2 +0,0 @@ -# the OpenAPI document is provided as source (design-first), no annotation scan needed -mp.openapi.scan.disable = true diff --git a/design-first-swagger-openliberty/src/main/webapp/META-INF/openapi.yaml b/design-first-swagger-openliberty/src/main/webapp/META-INF/openapi.yaml deleted file mode 100644 index 878efa3..0000000 --- a/design-first-swagger-openliberty/src/main/webapp/META-INF/openapi.yaml +++ /dev/null @@ -1,125 +0,0 @@ -openapi: 3.0.0 -info: - title: txproc-design-first-swagger-openliberty - version: "0.9" -servers: - - url: http://localhost:8080 -paths: - /api/txproc/pincheck: - post: - summary: Check the pin - operationId: pinCheck - requestBody: - description: PIN Check Request Body - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckRequest' - responses: - default: - description: PIN Check Response - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckResponse' - /api/txproc/purchase: - post: - summary: Authorize a Purchase - operationId: purchase - requestBody: - description: Purchase Request Body - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthRequest' - responses: - default: - description: Purchase Response - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthResponse' -components: - schemas: - EmvTags: - description: Collection of EMV tags - title: EmvTags - type: object - properties: - 84: - description: The EMV AID as reported by ICC - title: Dedicated Filename - type: string - 9F1A: - description: Terminal Country Code - type: string - Pan: - description: The number embossed on credit cards - title: PAN (Primary Account Number) - # type: string would make Swagger-UI prettier, but can't use own type - type: object - format: string - PinCheckRequest: - description: Request for checking a PIN - required: - - pan - - pinBlock - - uuid - properties: - pan: - $ref: '#/components/schemas/Pan' - pinBlock: - description: |- - Encrypted binary data containing a PIN - - Fieldcode: C003 - type: string - uuid: - description: Unique ID of the request - format: uuid - type: string - type: object - PinCheckResponse: - description: Tells if the PIN in the request was correct - properties: - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - tries: - description: Number of remaining tries - format: int32 - type: integer - type: object - PurchaseAuthRequest: - description: Request for authorizing a Purchase - required: - - pan - - uuid - properties: - emvTags: - $ref: '#/components/schemas/EmvTags' - pan: - $ref: '#/components/schemas/Pan' - uuid: - description: Unique ID of the request - format: uuid - type: string - type: object - PurchaseAuthResponse: - description: Response to PurchaseAuthRequest - properties: - approvalCode: - description: Code referencing the successful authorization - type: string - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - type: object diff --git a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java b/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java deleted file mode 100644 index 7c9d3e9..0000000 --- a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java +++ /dev/null @@ -1,94 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst; - -import static com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature.MINIMIZE_QUOTES; -import static io.restassured.RestAssured.given; -import static io.restassured.RestAssured.when; -import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertAll; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import javax.ws.rs.core.MediaType; - -import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.Test; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; - -import lombok.Getter; -import lombok.Setter; - -class OpenapiDocumentIT { - - @Getter - @Setter - static class OpenapiSkeleton { - String openapi; - Object info; - Object servers; - Object paths; - Object components; - Object security; - Object tags; - Object externalDocs; - } - - @Test - void openapi_yaml() throws IOException { - - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); - - String document = when().get("/openapi") - .then() - .statusCode(200) - .extract().response().asString(); - - String yamlSorted = sortYaml(document); - - assertAll("openapi yaml" - , () -> assertThat("unsorted", document, is(expected)) - , () -> assertThat("sorted", yamlSorted, is(expectedSorted)) - ); - } - - @Test - void openapi_json() throws IOException { - - String expected = loadResourceFile("openapi.json"); - - String document = given().accept(MediaType.APPLICATION_JSON) - .when().get("/openapi") - .then() - .statusCode(200) - .assertThat().contentType(MediaType.APPLICATION_JSON) - .extract().response().asString(); - - assertThat(document, jsonEquals(expected)); - } - - private String sortYaml(String yaml) throws IOException { - ObjectMapper yamlMapper = new ObjectMapper(new YAMLFactory().enable(MINIMIZE_QUOTES)); - OpenapiSkeleton objFromYaml = yamlMapper.readValue(yaml, OpenapiSkeleton.class); - - ObjectMapper jsonMapper = new ObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) - .configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); - String jsonSorted = jsonMapper.writeValueAsString(objFromYaml); - Object objFromJson = jsonMapper.readValue(jsonSorted, Object.class); - - return yamlMapper.writeValueAsString(objFromJson); - } - - private String loadResourceFile(String s) throws IOException { - return IOUtils.toString(getClass().getClassLoader().getResourceAsStream(s), StandardCharsets.UTF_8) - // needed on Windows depending on the Git configuration (core.autocrlf) - .replace("\r\n", "\n"); - } -} diff --git a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/generated/GenerationTest.java b/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/generated/GenerationTest.java deleted file mode 100644 index ec22ef1..0000000 --- a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/generated/GenerationTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.generated; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.apache.commons.io.IOUtils; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; - -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PinCheckRequest; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PinCheckResponse; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PurchaseAuthRequest; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PurchaseAuthResponse; - -class GenerationTest { - - private static final String FILE_SEPARATOR = System.getProperty("file.separator"); - - @ParameterizedTest - @ValueSource(classes = { - EmvTags.class, - PinCheckRequest.class, - PinCheckResponse.class, - PurchaseAuthRequest.class, - PurchaseAuthResponse.class - }) - void compare_generated_classes(Class clazz) throws IOException { - - String generated = loadGeneratedSourceFile(clazz); - String expected = loadExpectedSourceFile(clazz); - - assertThat(generated, is(expected)); - } - - private String loadGeneratedSourceFile(Class clazz) throws IOException { - - // set in maven pom.xml or the run configuration - String directoryGenerated = System.getProperty("generated.path"); - String generatedSourcePath = clazz.getName().replace(".", FILE_SEPARATOR) + ".java"; - Path path = Paths.get(directoryGenerated, generatedSourcePath); - - return IOUtils.toString(path.toUri(), StandardCharsets.UTF_8); - } - - private String loadExpectedSourceFile(Class clazz) throws IOException { - - String fileName = clazz.getSimpleName() + ".java.txt"; - return IOUtils.toString(getClass().getClassLoader().getResourceAsStream(fileName), StandardCharsets.UTF_8) - // needed on Windows depending on the Git configuration (core.autocrlf) - .replace("\r\n", "\n"); - } -} diff --git a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java b/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java deleted file mode 100644 index 6e2928c..0000000 --- a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java +++ /dev/null @@ -1,27 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; - -import javax.ws.rs.core.MediaType; - -import org.junit.jupiter.api.Test; - -class TxProcPincheckIT { - - @Test - void pincheck_ok() { - // @formatter:off - given() - .header("Content-Type", MediaType.APPLICATION_JSON) - .body("{\"uuid\": \"aaaaaaaa-bbbb-cccc-dddd-012345678901\", \"pinBlock\": \"magic\"}") - .when() - .post("/api/txproc/pincheck") - .then() - .statusCode(200) - .body("result", is("OK")) - .body("tries", is(3)) - ; - // @formatter:off - } -} \ No newline at end of file diff --git a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java b/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java deleted file mode 100644 index c262064..0000000 --- a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java +++ /dev/null @@ -1,29 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.rest; - -import static io.restassured.RestAssured.given; -import static org.hamcrest.CoreMatchers.is; - -import javax.ws.rs.core.MediaType; - -import org.junit.jupiter.api.Test; - -class TxProcPurchaseIT { - - @Test - void purchase_ok() { - // @formatter:off - given() - .header("Content-Type", MediaType.APPLICATION_JSON) - .body("{\"uuid\": \"aaaaaaaa-bbbb-cccc-dddd-012345678901\"," - +" \"pan\": \"4244333322221111\"," - +" \"emvTags\": { \"84\": \"A0000000041010\", \"9f1A\": \"250\" } }") - .when() - .post("/api/txproc/purchase") - .then() - .statusCode(200) - .body("result", is("OK")) - .body("approvalCode", is("OK42.250")) - ; - // @formatter:off - } -} \ No newline at end of file diff --git a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java b/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java deleted file mode 100644 index a4f118b..0000000 --- a/design-first-swagger-openliberty/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model; - -import static ch.schlau.pesche.apidocs.swagger.designfirst.rest.JsonConfiguration.JSONB; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; - -import javax.json.bind.Jsonb; - -import org.junit.jupiter.api.Test; - -class PanTest { - - @Test - void asMaskedPan_valid() { - - assertThat(new Pan("123456789012").asMaskedPan(), is("123456xx9012")); - assertThat(new Pan("1234567890123456789").asMaskedPan(), is("123456xxxxxxxxx6789")); - } - - @Test - void asMaskedPan_invalid() { - - assertThat(new Pan(null).asMaskedPan(), is(nullValue())); - assertThat(new Pan("1234567890").asMaskedPan(), is("1234567890")); - assertThat(new Pan("12345678901234567890").asMaskedPan(), is("12345678901234567890")); - } - - @Test - void json_roundtrip() { - - Jsonb jsonb = JSONB; - - Pan pan = new Pan("4444333322221111"); - - // JSON serialization - String jsonString = jsonb.toJson(pan); - assertThat(jsonString, is("\"4444333322221111\"")); - - // JSON deserialization - Pan roundtrip = jsonb.fromJson(jsonString, Pan.class); - assertThat(roundtrip.getPan(), is("4444333322221111")); - } -} \ No newline at end of file diff --git a/design-first-swagger-openliberty/src/test/resources/.editorconfig b/design-first-swagger-openliberty/src/test/resources/.editorconfig deleted file mode 100644 index 42344b9..0000000 --- a/design-first-swagger-openliberty/src/test/resources/.editorconfig +++ /dev/null @@ -1,2 +0,0 @@ -[*.txt] -trim_trailing_whitespace = false diff --git a/design-first-swagger-openliberty/src/test/resources/EmvTags.java.txt b/design-first-swagger-openliberty/src/test/resources/EmvTags.java.txt deleted file mode 100644 index aef444d..0000000 --- a/design-first-swagger-openliberty/src/test/resources/EmvTags.java.txt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * txproc-design-first-swagger-openliberty - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 0.9 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -/** - * Collection of EMV tags - */ -@Schema(description = "Collection of EMV tags") - -public class EmvTags { - @JsonProperty("84") - private String _84 = null; - - @JsonProperty("9F1A") - private String _9f1A = null; - - public EmvTags _84(String _84) { - this._84 = _84; - return this; - } - - /** - * The EMV AID as reported by ICC - * @return _84 - **/ - @Schema(description = "The EMV AID as reported by ICC") - public String get84() { - return _84; - } - - public void set84(String _84) { - this._84 = _84; - } - - public EmvTags _9f1A(String _9f1A) { - this._9f1A = _9f1A; - return this; - } - - /** - * Terminal Country Code - * @return _9f1A - **/ - @Schema(description = "Terminal Country Code") - public String get9f1A() { - return _9f1A; - } - - public void set9f1A(String _9f1A) { - this._9f1A = _9f1A; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - EmvTags emvTags = (EmvTags) o; - return Objects.equals(this._84, emvTags._84) && - Objects.equals(this._9f1A, emvTags._9f1A); - } - - @Override - public int hashCode() { - return Objects.hash(_84, _9f1A); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class EmvTags {\n"); - - sb.append(" _84: ").append(toIndentedString(_84)).append("\n"); - sb.append(" _9f1A: ").append(toIndentedString(_9f1A)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt b/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt deleted file mode 100644 index d23a3e6..0000000 --- a/design-first-swagger-openliberty/src/test/resources/PinCheckRequest.java.txt +++ /dev/null @@ -1,136 +0,0 @@ -/* - * txproc-design-first-swagger-openliberty - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 0.9 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; - -import java.util.Objects; -import java.util.Arrays; -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; -/** - * Request for checking a PIN - */ -@Schema(description = "Request for checking a PIN") - -public class PinCheckRequest { - @JsonProperty("pan") - private Pan pan = null; - - @JsonProperty("pinBlock") - private String pinBlock = null; - - @JsonProperty("uuid") - private UUID uuid = null; - - public PinCheckRequest pan(Pan pan) { - this.pan = pan; - return this; - } - - /** - * Get pan - * @return pan - **/ - @Schema(required = true, description = "") - public Pan getPan() { - return pan; - } - - public void setPan(Pan pan) { - this.pan = pan; - } - - public PinCheckRequest pinBlock(String pinBlock) { - this.pinBlock = pinBlock; - return this; - } - - /** - * Encrypted binary data containing a PIN Fieldcode: C003 - * @return pinBlock - **/ - @Schema(required = true, description = "Encrypted binary data containing a PIN Fieldcode: C003") - public String getPinBlock() { - return pinBlock; - } - - public void setPinBlock(String pinBlock) { - this.pinBlock = pinBlock; - } - - public PinCheckRequest uuid(UUID uuid) { - this.uuid = uuid; - return this; - } - - /** - * Unique ID of the request - * @return uuid - **/ - @Schema(required = true, description = "Unique ID of the request") - public UUID getUuid() { - return uuid; - } - - public void setUuid(UUID uuid) { - this.uuid = uuid; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PinCheckRequest pinCheckRequest = (PinCheckRequest) o; - return Objects.equals(this.pan, pinCheckRequest.pan) && - Objects.equals(this.pinBlock, pinCheckRequest.pinBlock) && - Objects.equals(this.uuid, pinCheckRequest.uuid); - } - - @Override - public int hashCode() { - return Objects.hash(pan, pinBlock, uuid); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PinCheckRequest {\n"); - - sb.append(" pan: ").append(toIndentedString(pan)).append("\n"); - sb.append(" pinBlock: ").append(toIndentedString(pinBlock)).append("\n"); - sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/design-first-swagger-openliberty/src/test/resources/PinCheckResponse.java.txt b/design-first-swagger-openliberty/src/test/resources/PinCheckResponse.java.txt deleted file mode 100644 index c71b99d..0000000 --- a/design-first-swagger-openliberty/src/test/resources/PinCheckResponse.java.txt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * txproc-design-first-swagger-openliberty - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 0.9 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -/** - * Tells if the PIN in the request was correct - */ -@Schema(description = "Tells if the PIN in the request was correct") - -public class PinCheckResponse { - /** - * Result of the request - */ - public enum ResultEnum { - OK("OK"), - WRONG("WRONG"); - - private String value; - - ResultEnum(String value) { - this.value = value; - } - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - @JsonCreator - public static ResultEnum fromValue(String text) { - for (ResultEnum b : ResultEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - } @JsonProperty("result") - private ResultEnum result = null; - - @JsonProperty("tries") - private Integer tries = null; - - public PinCheckResponse result(ResultEnum result) { - this.result = result; - return this; - } - - /** - * Result of the request - * @return result - **/ - @Schema(description = "Result of the request") - public ResultEnum getResult() { - return result; - } - - public void setResult(ResultEnum result) { - this.result = result; - } - - public PinCheckResponse tries(Integer tries) { - this.tries = tries; - return this; - } - - /** - * Number of remaining tries - * @return tries - **/ - @Schema(description = "Number of remaining tries") - public Integer getTries() { - return tries; - } - - public void setTries(Integer tries) { - this.tries = tries; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PinCheckResponse pinCheckResponse = (PinCheckResponse) o; - return Objects.equals(this.result, pinCheckResponse.result) && - Objects.equals(this.tries, pinCheckResponse.tries); - } - - @Override - public int hashCode() { - return Objects.hash(result, tries); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PinCheckResponse {\n"); - - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append(" tries: ").append(toIndentedString(tries)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt deleted file mode 100644 index a850e51..0000000 --- a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthRequest.java.txt +++ /dev/null @@ -1,137 +0,0 @@ -/* - * txproc-design-first-swagger-openliberty - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 0.9 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; - -import java.util.Objects; -import java.util.Arrays; -import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.UUID; -/** - * Request for authorizing a Purchase - */ -@Schema(description = "Request for authorizing a Purchase") - -public class PurchaseAuthRequest { - @JsonProperty("emvTags") - private EmvTags emvTags = null; - - @JsonProperty("pan") - private Pan pan = null; - - @JsonProperty("uuid") - private UUID uuid = null; - - public PurchaseAuthRequest emvTags(EmvTags emvTags) { - this.emvTags = emvTags; - return this; - } - - /** - * Get emvTags - * @return emvTags - **/ - @Schema(description = "") - public EmvTags getEmvTags() { - return emvTags; - } - - public void setEmvTags(EmvTags emvTags) { - this.emvTags = emvTags; - } - - public PurchaseAuthRequest pan(Pan pan) { - this.pan = pan; - return this; - } - - /** - * Get pan - * @return pan - **/ - @Schema(required = true, description = "") - public Pan getPan() { - return pan; - } - - public void setPan(Pan pan) { - this.pan = pan; - } - - public PurchaseAuthRequest uuid(UUID uuid) { - this.uuid = uuid; - return this; - } - - /** - * Unique ID of the request - * @return uuid - **/ - @Schema(required = true, description = "Unique ID of the request") - public UUID getUuid() { - return uuid; - } - - public void setUuid(UUID uuid) { - this.uuid = uuid; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PurchaseAuthRequest purchaseAuthRequest = (PurchaseAuthRequest) o; - return Objects.equals(this.emvTags, purchaseAuthRequest.emvTags) && - Objects.equals(this.pan, purchaseAuthRequest.pan) && - Objects.equals(this.uuid, purchaseAuthRequest.uuid); - } - - @Override - public int hashCode() { - return Objects.hash(emvTags, pan, uuid); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PurchaseAuthRequest {\n"); - - sb.append(" emvTags: ").append(toIndentedString(emvTags)).append("\n"); - sb.append(" pan: ").append(toIndentedString(pan)).append("\n"); - sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthResponse.java.txt b/design-first-swagger-openliberty/src/test/resources/PurchaseAuthResponse.java.txt deleted file mode 100644 index 51ad8e6..0000000 --- a/design-first-swagger-openliberty/src/test/resources/PurchaseAuthResponse.java.txt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * txproc-design-first-swagger-openliberty - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 0.9 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; - -import java.util.Objects; -import java.util.Arrays; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -/** - * Response to PurchaseAuthRequest - */ -@Schema(description = "Response to PurchaseAuthRequest") - -public class PurchaseAuthResponse { - @JsonProperty("approvalCode") - private String approvalCode = null; - - /** - * Result of the request - */ - public enum ResultEnum { - OK("OK"), - WRONG("WRONG"); - - private String value; - - ResultEnum(String value) { - this.value = value; - } - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - @JsonCreator - public static ResultEnum fromValue(String text) { - for (ResultEnum b : ResultEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - } @JsonProperty("result") - private ResultEnum result = null; - - public PurchaseAuthResponse approvalCode(String approvalCode) { - this.approvalCode = approvalCode; - return this; - } - - /** - * Code referencing the successful authorization - * @return approvalCode - **/ - @Schema(description = "Code referencing the successful authorization") - public String getApprovalCode() { - return approvalCode; - } - - public void setApprovalCode(String approvalCode) { - this.approvalCode = approvalCode; - } - - public PurchaseAuthResponse result(ResultEnum result) { - this.result = result; - return this; - } - - /** - * Result of the request - * @return result - **/ - @Schema(description = "Result of the request") - public ResultEnum getResult() { - return result; - } - - public void setResult(ResultEnum result) { - this.result = result; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PurchaseAuthResponse purchaseAuthResponse = (PurchaseAuthResponse) o; - return Objects.equals(this.approvalCode, purchaseAuthResponse.approvalCode) && - Objects.equals(this.result, purchaseAuthResponse.result); - } - - @Override - public int hashCode() { - return Objects.hash(approvalCode, result); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PurchaseAuthResponse {\n"); - - sb.append(" approvalCode: ").append(toIndentedString(approvalCode)).append("\n"); - sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/design-first-swagger-openliberty/src/test/resources/openapi-sorted.yaml b/design-first-swagger-openliberty/src/test/resources/openapi-sorted.yaml deleted file mode 100644 index e6a9464..0000000 --- a/design-first-swagger-openliberty/src/test/resources/openapi-sorted.yaml +++ /dev/null @@ -1,125 +0,0 @@ ---- -openapi: 3.0.0 -info: - title: txproc-design-first-swagger-openliberty - version: 0.9 -servers: -- url: http://localhost:8080 -paths: - /api/txproc/pincheck: - post: - operationId: pinCheck - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckRequest' - description: PIN Check Request Body - required: true - responses: - default: - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckResponse' - description: PIN Check Response - summary: Check the pin - /api/txproc/purchase: - post: - operationId: purchase - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthRequest' - description: Purchase Request Body - required: true - responses: - default: - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthResponse' - description: Purchase Response - summary: Authorize a Purchase -components: - schemas: - EmvTags: - description: Collection of EMV tags - properties: - "84": - description: The EMV AID as reported by ICC - title: Dedicated Filename - type: string - "9F1A": - description: Terminal Country Code - type: string - title: EmvTags - type: object - Pan: - description: The number embossed on credit cards - format: string - title: PAN (Primary Account Number) - type: object - PinCheckRequest: - description: Request for checking a PIN - properties: - pan: - $ref: '#/components/schemas/Pan' - pinBlock: - description: |- - Encrypted binary data containing a PIN - - Fieldcode: C003 - type: string - uuid: - description: Unique ID of the request - format: uuid - type: string - required: - - pan - - pinBlock - - uuid - type: object - PinCheckResponse: - description: Tells if the PIN in the request was correct - properties: - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - tries: - description: Number of remaining tries - format: int32 - type: integer - type: object - PurchaseAuthRequest: - description: Request for authorizing a Purchase - properties: - emvTags: - $ref: '#/components/schemas/EmvTags' - pan: - $ref: '#/components/schemas/Pan' - uuid: - description: Unique ID of the request - format: uuid - type: string - required: - - pan - - uuid - type: object - PurchaseAuthResponse: - description: Response to PurchaseAuthRequest - properties: - approvalCode: - description: Code referencing the successful authorization - type: string - result: - description: Result of the request - enum: - - OK - - WRONG - type: string - type: object diff --git a/design-first-swagger-openliberty/src/test/resources/openapi.json b/design-first-swagger-openliberty/src/test/resources/openapi.json deleted file mode 100644 index 4e1ba12..0000000 --- a/design-first-swagger-openliberty/src/test/resources/openapi.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "txproc-design-first-swagger-openliberty", - "version": "0.9" - }, - "servers": [ - { - "url": "http://localhost:8080" - } - ], - "paths": { - "/api/txproc/pincheck": { - "post": { - "summary": "Check the pin", - "operationId": "pinCheck", - "requestBody": { - "description": "PIN Check Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" - } - } - }, - "required": true - }, - "responses": { - "default": { - "description": "PIN Check Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" - } - } - } - } - } - } - }, - "/api/txproc/purchase": { - "post": { - "summary": "Authorize a Purchase", - "operationId": "purchase", - "requestBody": { - "description": "Purchase Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" - } - } - }, - "required": true - }, - "responses": { - "default": { - "description": "Purchase Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "EmvTags": { - "title": "EmvTags", - "type": "object", - "properties": { - "84": { - "title": "Dedicated Filename", - "type": "string", - "description": "The EMV AID as reported by ICC" - }, - "9F1A": { - "type": "string", - "description": "Terminal Country Code" - } - }, - "description": "Collection of EMV tags" - }, - "Pan": { - "title": "PAN (Primary Account Number)", - "type": "object", - "description": "The number embossed on credit cards", - "format": "string" - }, - "PinCheckRequest": { - "required": [ - "pan", - "pinBlock", - "uuid" - ], - "type": "object", - "properties": { - "pan": { - "$ref": "#/components/schemas/Pan" - }, - "pinBlock": { - "type": "string", - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003" - }, - "uuid": { - "type": "string", - "description": "Unique ID of the request", - "format": "uuid" - } - }, - "description": "Request for checking a PIN" - }, - "PinCheckResponse": { - "type": "object", - "properties": { - "result": { - "type": "string", - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ] - }, - "tries": { - "type": "integer", - "description": "Number of remaining tries", - "format": "int32" - } - }, - "description": "Tells if the PIN in the request was correct" - }, - "PurchaseAuthRequest": { - "required": [ - "pan", - "uuid" - ], - "type": "object", - "properties": { - "emvTags": { - "$ref": "#/components/schemas/EmvTags" - }, - "pan": { - "$ref": "#/components/schemas/Pan" - }, - "uuid": { - "type": "string", - "description": "Unique ID of the request", - "format": "uuid" - } - }, - "description": "Request for authorizing a Purchase" - }, - "PurchaseAuthResponse": { - "type": "object", - "properties": { - "approvalCode": { - "type": "string", - "description": "Code referencing the successful authorization" - }, - "result": { - "type": "string", - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ] - } - }, - "description": "Response to PurchaseAuthRequest" - } - } - } -} diff --git a/design-first-swagger-openliberty/src/test/resources/openapi.yaml b/design-first-swagger-openliberty/src/test/resources/openapi.yaml deleted file mode 100644 index ffe39e5..0000000 --- a/design-first-swagger-openliberty/src/test/resources/openapi.yaml +++ /dev/null @@ -1,124 +0,0 @@ -openapi: 3.0.0 -info: - title: txproc-design-first-swagger-openliberty - version: "0.9" -servers: -- url: http://localhost:8080 -paths: - /api/txproc/pincheck: - post: - summary: Check the pin - operationId: pinCheck - requestBody: - description: PIN Check Request Body - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckRequest' - required: true - responses: - default: - description: PIN Check Response - content: - application/json: - schema: - $ref: '#/components/schemas/PinCheckResponse' - /api/txproc/purchase: - post: - summary: Authorize a Purchase - operationId: purchase - requestBody: - description: Purchase Request Body - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthRequest' - required: true - responses: - default: - description: Purchase Response - content: - application/json: - schema: - $ref: '#/components/schemas/PurchaseAuthResponse' -components: - schemas: - EmvTags: - title: EmvTags - type: object - properties: - 84: - title: Dedicated Filename - type: string - description: The EMV AID as reported by ICC - 9F1A: - type: string - description: Terminal Country Code - description: Collection of EMV tags - Pan: - title: PAN (Primary Account Number) - type: object - description: The number embossed on credit cards - format: string - PinCheckRequest: - required: - - pan - - pinBlock - - uuid - type: object - properties: - pan: - $ref: '#/components/schemas/Pan' - pinBlock: - type: string - description: |- - Encrypted binary data containing a PIN - - Fieldcode: C003 - uuid: - type: string - description: Unique ID of the request - format: uuid - description: Request for checking a PIN - PinCheckResponse: - type: object - properties: - result: - type: string - description: Result of the request - enum: - - OK - - WRONG - tries: - type: integer - description: Number of remaining tries - format: int32 - description: Tells if the PIN in the request was correct - PurchaseAuthRequest: - required: - - pan - - uuid - type: object - properties: - emvTags: - $ref: '#/components/schemas/EmvTags' - pan: - $ref: '#/components/schemas/Pan' - uuid: - type: string - description: Unique ID of the request - format: uuid - description: Request for authorizing a Purchase - PurchaseAuthResponse: - type: object - properties: - approvalCode: - type: string - description: Code referencing the successful authorization - result: - type: string - description: Result of the request - enum: - - OK - - WRONG - description: Response to PurchaseAuthRequest diff --git a/design-first-swagger-openliberty/src/test/resources/rest-api.http b/design-first-swagger-openliberty/src/test/resources/rest-api.http deleted file mode 100644 index 6aee14d..0000000 --- a/design-first-swagger-openliberty/src/test/resources/rest-api.http +++ /dev/null @@ -1,35 +0,0 @@ -# Swagger/OpenAPI in YAML format -GET http://localhost:8080/openapi - -### - -# Swagger/OpenAPI in JSON format -GET http://localhost:8080/openapi -Accept: application/json - -### - -POST http://localhost:8080/api/txproc/pincheck -Content-Type: application/json - -{ - "uuid": "aaaaaaaa-bbbb-cccc-dddd-012345678901", - "pan" : "100000000042", - "pinBlock": "magic" -} - -### - -POST http://localhost:8080/api/txproc/purchase -Content-Type: application/json - -{ - "uuid": "aaaaaaaa-bbbb-cccc-dddd-012345678901", - "pan": "4244333322221111", - "emvTags": { - "84" : "A0000000041010", - "9f1A" : "250" - } -} - -### diff --git a/pom.xml b/pom.xml index ade5e8c..8ab7009 100644 --- a/pom.xml +++ b/pom.xml @@ -10,11 +10,9 @@ pom - code-first-openapi-openliberty code-first-openapi-quarkus code-first-swagger design-first-openapi-generator design-first-swagger-quarkus - design-first-swagger-openliberty From afa2e622287b07c19c65ba98ad27303910e84bbd Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Sun, 6 Aug 2023 14:41:34 +0200 Subject: [PATCH 05/12] Up to Quarkus 3.2, Jakarta EE 10, generator 6.6.0 --- code-first-openapi-quarkus/.editorconfig | 19 ++ code-first-openapi-quarkus/pom.xml | 12 +- .../codefirst/rest/JaxrsApplication.java | 4 +- .../codefirst/rest/JsonConfiguration.java | 6 +- .../codefirst/rest/JsonContextResolver.java | 6 +- .../openapi/codefirst/rest/TxProc.java | 10 +- .../codefirst/txproc/model/EmvTags.java | 2 +- .../openapi/codefirst/txproc/model/Pan.java | 2 +- .../txproc/model/PanJsonAdapter.java | 2 +- .../META-INF/microprofile-config.properties | 8 +- .../openapi/codefirst/OpenapiDocumentIT.java | 2 +- .../codefirst/rest/TxProcPincheckIT.java | 2 +- .../codefirst/rest/TxProcPurchaseIT.java | 2 +- .../codefirst/txproc/model/EmvTagsTest.java | 2 +- .../codefirst/txproc/model/PanTest.java | 2 +- .../src/test/resources/openapi-sorted.yaml | 33 ++- .../src/test/resources/openapi.json | 243 +++++++++--------- .../src/test/resources/openapi.yaml | 101 ++++---- code-first-swagger/.editorconfig | 19 ++ code-first-swagger/README.md | 4 + code-first-swagger/pom.xml | 16 +- .../codefirst/rest/JaxrsApplication.java | 4 +- .../codefirst/rest/JsonConfiguration.java | 6 +- .../codefirst/rest/JsonContextResolver.java | 6 +- .../swagger/codefirst/rest/TxProc.java | 10 +- .../codefirst/txproc/model/EmvTags.java | 2 +- .../swagger/codefirst/txproc/model/Pan.java | 2 +- .../txproc/model/PanJsonAdapter.java | 2 +- .../META-INF/microprofile-config.properties | 4 + .../swagger/codefirst/OpenapiDocumentIT.java | 2 +- .../codefirst/rest/TxProcPincheckIT.java | 2 +- .../codefirst/rest/TxProcPurchaseIT.java | 2 +- .../codefirst/txproc/model/EmvTagsTest.java | 2 +- .../codefirst/txproc/model/PanTest.java | 2 +- .../src/test/resources/openapi-sorted.yaml | 7 +- .../src/test/resources/openapi.json | 11 +- .../src/test/resources/openapi.yaml | 11 +- design-first-openapi-generator/.editorconfig | 19 ++ design-first-openapi-generator/pom.xml | 33 ++- .../designfirst/rest/JaxrsApplication.java | 4 +- .../designfirst/rest/JsonConfiguration.java | 6 +- .../designfirst/rest/JsonContextResolver.java | 6 +- .../openapi/designfirst/rest/TxProc.java | 10 +- .../openapi/designfirst/txproc/model/Pan.java | 2 +- .../txproc/model/PanJsonAdapter.java | 2 +- .../META-INF/microprofile-config.properties | 4 + .../src/main/resources/META-INF/openapi.yaml | 4 +- .../designfirst/OpenapiDocumentIT.java | 2 +- .../designfirst/rest/TxProcPincheckIT.java | 2 +- .../designfirst/rest/TxProcPurchaseIT.java | 2 +- .../designfirst/txproc/model/PanTest.java | 2 +- .../src/test/resources/EmvTags.java.txt | 32 ++- .../test/resources/PinCheckRequest.java.txt | 35 ++- .../test/resources/PinCheckResponse.java.txt | 32 ++- .../resources/PurchaseAuthRequest.java.txt | 36 +-- .../resources/PurchaseAuthResponse.java.txt | 32 ++- .../src/test/resources/openapi-sorted.yaml | 7 +- .../src/test/resources/openapi.json | 11 +- .../src/test/resources/openapi.yaml | 7 +- design-first-swagger-quarkus/.editorconfig | 19 ++ design-first-swagger-quarkus/pom.xml | 25 +- .../designfirst/rest/JaxrsApplication.java | 4 +- .../designfirst/rest/JsonConfiguration.java | 6 +- .../designfirst/rest/JsonContextResolver.java | 6 +- .../swagger/designfirst/rest/TxProc.java | 10 +- .../swagger/designfirst/txproc/model/Pan.java | 2 +- .../txproc/model/PanJsonAdapter.java | 2 +- .../META-INF/microprofile-config.properties | 4 + .../src/main/resources/META-INF/openapi.yaml | 4 +- .../designfirst/OpenapiDocumentIT.java | 2 +- .../designfirst/rest/TxProcPincheckIT.java | 2 +- .../designfirst/rest/TxProcPurchaseIT.java | 2 +- .../designfirst/txproc/model/PanTest.java | 2 +- .../src/test/resources/EmvTags.java.txt | 1 + .../test/resources/PinCheckRequest.java.txt | 1 + .../test/resources/PinCheckResponse.java.txt | 5 +- .../resources/PurchaseAuthRequest.java.txt | 1 + .../resources/PurchaseAuthResponse.java.txt | 5 +- .../src/test/resources/openapi-sorted.yaml | 7 +- .../src/test/resources/openapi.json | 9 +- .../src/test/resources/openapi.yaml | 7 +- 81 files changed, 593 insertions(+), 395 deletions(-) create mode 100644 code-first-openapi-quarkus/.editorconfig create mode 100644 code-first-swagger/.editorconfig create mode 100644 design-first-openapi-generator/.editorconfig create mode 100644 design-first-swagger-quarkus/.editorconfig diff --git a/code-first-openapi-quarkus/.editorconfig b/code-first-openapi-quarkus/.editorconfig new file mode 100644 index 0000000..222d8e4 --- /dev/null +++ b/code-first-openapi-quarkus/.editorconfig @@ -0,0 +1,19 @@ +# editor configuration containing values that are different from the IntelliJ default + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space + +[*.java] +ij_java_imports_layout = $*, |, java.**, |, jakarta.**, javax.**, |, oracle.**, |, org.**, |, com.**, |, * + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_line_comment_at_first_column = false + +[{*.har,*.jsb2,*.jsb3,*.json,*.ndjson,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_indent_sequence_value = false diff --git a/code-first-openapi-quarkus/pom.xml b/code-first-openapi-quarkus/pom.xml index cdaf0df..84b519f 100755 --- a/code-first-openapi-quarkus/pom.xml +++ b/code-first-openapi-quarkus/pom.xml @@ -17,16 +17,16 @@ 11 - 1.18.10 - 1.5.0.Final + 1.18.28 + 3.2.3.Final 2.2 - 2.10.0 + 2.38.0 - 3.8.1 - 2.22.2 + 3.11.0 + 3.1.2 @@ -42,7 +42,7 @@ - + io.quarkus quarkus-resteasy-jsonb diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java index a611465..748104e 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JaxrsApplication.java @@ -1,7 +1,7 @@ package ch.schlau.pesche.apidocs.openapi.codefirst.rest; -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition; import org.eclipse.microprofile.openapi.annotations.info.Info; diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java index 8920fd5..0389554 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonConfiguration.java @@ -1,8 +1,8 @@ package ch.schlau.pesche.apidocs.openapi.codefirst.rest; -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model.PanJsonAdapter; import lombok.experimental.UtilityClass; diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java index f0b6307..4046be1 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/JsonContextResolver.java @@ -2,9 +2,9 @@ import static ch.schlau.pesche.apidocs.openapi.codefirst.rest.JsonConfiguration.JSONB; -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; +import jakarta.json.bind.Jsonb; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; @Provider public class JsonContextResolver implements ContextResolver { diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java index 97582d4..a5c6d6f 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProc.java @@ -2,11 +2,11 @@ import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import org.eclipse.microprofile.openapi.annotations.Operation; import org.eclipse.microprofile.openapi.annotations.media.Content; diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java index 6dd9b2d..f481404 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTags.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; -import javax.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbProperty; import org.eclipse.microprofile.openapi.annotations.media.Schema; diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java index ba241d9..db4e2a5 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/Pan.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; -import javax.validation.constraints.Pattern; +import jakarta.validation.constraints.Pattern; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; import org.eclipse.microprofile.openapi.annotations.media.Schema; diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java index 9852212..524146f 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanJsonAdapter.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.openapi.codefirst.txproc.model; -import javax.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.adapter.JsonbAdapter; public class PanJsonAdapter implements JsonbAdapter { @Override diff --git a/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties b/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties index 7a8727f..7b4e1c9 100644 --- a/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties +++ b/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties @@ -1,7 +1,5 @@ # Smallrye-specific options -# I tried to set this option, because nested classes like EmvTags are not -# referenced, but copied inline, see also https://github.com/smallrye/smallrye-open-api/issues/73 -# but this option then references all classes, also String and Integer -# mp.openapi.extensions.schema-references.enable = true -# mp.openapi.scan.packages = ch.schlau.pesche.apidocs.openapi.codefirst.txproc +# keep /openapi instead /q/openapi for the time being +# see https://quarkus.io/blog/path-resolution-in-quarkus/ +quarkus.http.non-application-root-path=${quarkus.http.root-path} diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java index 0b92b92..8aac12e 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java index 7e43adb..6ce1c1c 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPincheckIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java index d9bb04f..9ec1b2b 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/rest/TxProcPurchaseIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java index 1fb8daa..bcf27e8 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/EmvTagsTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java index 4602499..1f06054 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/model/PanTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml index 6be0740..0dc1c08 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml +++ b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.1 +openapi: 3.0.3 info: title: txproc-code-first-openapi version: 0.9 @@ -21,6 +21,8 @@ paths: $ref: '#/components/schemas/PinCheckResponse' description: PIN Check Response summary: Check the pin + tags: + - Tx Proc /api/txproc/purchase: post: requestBody: @@ -38,6 +40,8 @@ paths: $ref: '#/components/schemas/PurchaseAuthResponse' description: Purchase Response summary: Authorize a Purchase + tags: + - Tx Proc components: schemas: Code: @@ -63,9 +67,7 @@ components: title: EmvTags type: object Pan: - description: The number embossed on credit cards - title: PAN (Primary Account Number) - type: string + $ref: '#/components/schemas/Pan' PinCheckRequest: description: Request for checking a PIN properties: @@ -80,7 +82,8 @@ components: uuid: allOf: - $ref: '#/components/schemas/UUID' - - description: Unique ID of the request + description: Unique ID of the request + type: string required: - uuid - pan @@ -91,8 +94,9 @@ components: properties: result: allOf: - - $ref: '#/components/schemas/Code' - - description: Result of the request + - $ref: '#/components/schemas/Code1' + description: Result of the request + type: string tries: description: Number of remaining tries format: int32 @@ -108,7 +112,8 @@ components: uuid: allOf: - $ref: '#/components/schemas/UUID' - - description: Unique ID of the request + description: Unique ID of the request + type: string required: - uuid - pan @@ -121,10 +126,16 @@ components: type: string result: allOf: - - $ref: '#/components/schemas/Code1' - - description: Result of the request + - $ref: '#/components/schemas/Code' + description: Result of the request + type: string type: object UUID: format: uuid - pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}' + pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" type: string + securitySchemes: + SecurityScheme: + description: Authentication + scheme: basic + type: http diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json b/code-first-openapi-quarkus/src/test/resources/openapi.json index 3c61aba..8404477 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json @@ -1,4 +1,73 @@ { + "openapi": "3.0.3", + "info": { + "title": "txproc-code-first-openapi", + "version": "0.9" + }, + "paths": { + "/api/txproc/pincheck": { + "post": { + "tags": [ + "Tx Proc" + ], + "summary": "Check the pin", + "requestBody": { + "description": "PIN Check Request Body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PinCheckRequest" + } + } + }, + "required": true + }, + "responses": { + "default": { + "description": "PIN Check Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PinCheckResponse" + } + } + } + } + } + } + }, + "/api/txproc/purchase": { + "post": { + "tags": [ + "Tx Proc" + ], + "summary": "Authorize a Purchase", + "requestBody": { + "description": "Purchase Request Body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PurchaseAuthRequest" + } + } + }, + "required": true + }, + "responses": { + "default": { + "description": "Purchase Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PurchaseAuthResponse" + } + } + } + } + } + } + } + }, "components": { "schemas": { "Code": { @@ -16,189 +85,127 @@ "type": "string" }, "EmvTags": { + "title": "EmvTags", "description": "Collection of EMV tags", + "type": "object", "properties": { "84": { - "description": "The EMV AID as reported by ICC", "title": "Dedicated Filename", + "description": "The EMV AID as reported by ICC", "type": "string" }, "9F1A": { "description": "Terminal Country Code", "type": "string" } - }, - "title": "EmvTags", - "type": "object" + } }, "Pan": { - "description": "The number embossed on credit cards", - "title": "PAN (Primary Account Number)", - "type": "string" + "$ref": "#/components/schemas/Pan" }, "PinCheckRequest": { "description": "Request for checking a PIN", + "required": [ + "uuid", + "pan", + "pinBlock" + ], + "type": "object", "properties": { - "pan": { - "$ref": "#/components/schemas/Pan" - }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" - }, "uuid": { + "description": "Unique ID of the request", + "type": "string", "allOf": [ { "$ref": "#/components/schemas/UUID" - }, - { - "description": "Unique ID of the request" } ] + }, + "pan": { + "$ref": "#/components/schemas/Pan" + }, + "pinBlock": { + "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", + "type": "string" } - }, - "required": [ - "uuid", - "pan", - "pinBlock" - ], - "type": "object" + } }, "PinCheckResponse": { "description": "Tells if the PIN in the request was correct", + "type": "object", "properties": { "result": { + "description": "Result of the request", + "type": "string", "allOf": [ { - "$ref": "#/components/schemas/Code" - }, - { - "description": "Result of the request" + "$ref": "#/components/schemas/Code1" } ] }, "tries": { - "description": "Number of remaining tries", "format": "int32", + "description": "Number of remaining tries", "type": "integer" } - }, - "type": "object" + } }, "PurchaseAuthRequest": { "description": "Request for authorizing a Purchase", + "required": [ + "uuid", + "pan" + ], + "type": "object", "properties": { - "emvTags": { - "$ref": "#/components/schemas/EmvTags" - }, - "pan": { - "$ref": "#/components/schemas/Pan" - }, "uuid": { + "description": "Unique ID of the request", + "type": "string", "allOf": [ { "$ref": "#/components/schemas/UUID" - }, - { - "description": "Unique ID of the request" } ] + }, + "pan": { + "$ref": "#/components/schemas/Pan" + }, + "emvTags": { + "$ref": "#/components/schemas/EmvTags" } - }, - "required": [ - "uuid", - "pan" - ], - "type": "object" + } }, "PurchaseAuthResponse": { "description": "Response to PurchaseAuthRequest", + "type": "object", "properties": { - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" - }, "result": { + "description": "Result of the request", + "type": "string", "allOf": [ { - "$ref": "#/components/schemas/Code1" - }, - { - "description": "Result of the request" + "$ref": "#/components/schemas/Code" } ] + }, + "approvalCode": { + "description": "Code referencing the successful authorization", + "type": "string" } - }, - "type": "object" + } }, "UUID": { "format": "uuid", "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "type": "string" } - } - }, - "info": { - "title": "txproc-code-first-openapi", - "version": "0.9" - }, - "openapi": "3.0.1", - "paths": { - "/api/txproc/pincheck": { - "post": { - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" - } - } - }, - "description": "PIN Check Request Body", - "required": true - }, - "responses": { - "default": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" - } - } - }, - "description": "PIN Check Response" - } - }, - "summary": "Check the pin" - } }, - "/api/txproc/purchase": { - "post": { - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" - } - } - }, - "description": "Purchase Request Body", - "required": true - }, - "responses": { - "default": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" - } - } - }, - "description": "Purchase Response" - } - }, - "summary": "Authorize a Purchase" + "securitySchemes": { + "SecurityScheme": { + "type": "http", + "description": "Authentication", + "scheme": "basic" } } } -} +} \ No newline at end of file diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml b/code-first-openapi-quarkus/src/test/resources/openapi.yaml index 0f0946b..626459b 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.yaml +++ b/code-first-openapi-quarkus/src/test/resources/openapi.yaml @@ -1,11 +1,13 @@ --- -openapi: 3.0.1 +openapi: 3.0.3 info: title: txproc-code-first-openapi version: "0.9" paths: /api/txproc/pincheck: post: + tags: + - Tx Proc summary: Check the pin requestBody: description: PIN Check Request Body @@ -23,6 +25,8 @@ paths: $ref: '#/components/schemas/PinCheckResponse' /api/txproc/purchase: post: + tags: + - Tx Proc summary: Authorize a Purchase requestBody: description: Purchase Request Body @@ -40,6 +44,30 @@ paths: $ref: '#/components/schemas/PurchaseAuthResponse' components: schemas: + Code: + enum: + - OK + - WRONG + type: string + Code1: + enum: + - OK + - WRONG + type: string + EmvTags: + title: EmvTags + description: Collection of EMV tags + type: object + properties: + "84": + title: Dedicated Filename + description: The EMV AID as reported by ICC + type: string + "9F1A": + description: Terminal Country Code + type: string + Pan: + $ref: '#/components/schemas/Pan' PinCheckRequest: description: Request for checking a PIN required: @@ -48,6 +76,11 @@ components: - pinBlock type: object properties: + uuid: + description: Unique ID of the request + type: string + allOf: + - $ref: '#/components/schemas/UUID' pan: $ref: '#/components/schemas/Pan' pinBlock: @@ -56,35 +89,19 @@ components: Fieldcode: C003 type: string - uuid: - allOf: - - $ref: '#/components/schemas/UUID' - - description: Unique ID of the request - Pan: - title: PAN (Primary Account Number) - description: The number embossed on credit cards - type: string - UUID: - format: uuid - pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}' - type: string PinCheckResponse: description: Tells if the PIN in the request was correct type: object properties: result: + description: Result of the request + type: string allOf: - - $ref: '#/components/schemas/Code' - - description: Result of the request + - $ref: '#/components/schemas/Code1' tries: format: int32 description: Number of remaining tries type: integer - Code: - enum: - - OK - - WRONG - type: string PurchaseAuthRequest: description: Request for authorizing a Purchase required: @@ -92,39 +109,33 @@ components: - pan type: object properties: - emvTags: - $ref: '#/components/schemas/EmvTags' - pan: - $ref: '#/components/schemas/Pan' uuid: + description: Unique ID of the request + type: string allOf: - $ref: '#/components/schemas/UUID' - - description: Unique ID of the request - EmvTags: - title: EmvTags - description: Collection of EMV tags - type: object - properties: - "84": - title: Dedicated Filename - description: The EMV AID as reported by ICC - type: string - "9F1A": - description: Terminal Country Code - type: string + pan: + $ref: '#/components/schemas/Pan' + emvTags: + $ref: '#/components/schemas/EmvTags' PurchaseAuthResponse: description: Response to PurchaseAuthRequest type: object properties: + result: + description: Result of the request + type: string + allOf: + - $ref: '#/components/schemas/Code' approvalCode: description: Code referencing the successful authorization type: string - result: - allOf: - - $ref: '#/components/schemas/Code1' - - description: Result of the request - Code1: - enum: - - OK - - WRONG + UUID: + format: uuid + pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" type: string + securitySchemes: + SecurityScheme: + type: http + description: Authentication + scheme: basic diff --git a/code-first-swagger/.editorconfig b/code-first-swagger/.editorconfig new file mode 100644 index 0000000..222d8e4 --- /dev/null +++ b/code-first-swagger/.editorconfig @@ -0,0 +1,19 @@ +# editor configuration containing values that are different from the IntelliJ default + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space + +[*.java] +ij_java_imports_layout = $*, |, java.**, |, jakarta.**, javax.**, |, oracle.**, |, org.**, |, com.**, |, * + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_line_comment_at_first_column = false + +[{*.har,*.jsb2,*.jsb3,*.json,*.ndjson,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_indent_sequence_value = false diff --git a/code-first-swagger/README.md b/code-first-swagger/README.md index b0d635d..c04e593 100644 --- a/code-first-swagger/README.md +++ b/code-first-swagger/README.md @@ -20,3 +20,7 @@ Once the service runs: - http://localhost:8080/openapi fetches the OpenAPI document - http://localhost:8080/swagger-ui shows an interactive view of the API (based on Swagger-UI) + +## Swagger Scanner + +Plugin source: [swagger-maven-plugin](https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-maven-plugin) diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 8e1c8c4..4b4686c 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -17,17 +17,17 @@ 11 - 1.18.10 - 1.5.0.Final - 2.1.2 + 1.18.28 + 3.2.3.Final + 2.2.15 2.2 - 2.10.0 + 2.38.0 - 3.8.1 - 2.22.2 + 3.11.0 + 3.1.2 @@ -43,7 +43,7 @@ - + io.quarkus quarkus-resteasy-jsonb @@ -103,7 +103,7 @@ io.swagger.core.v3 - swagger-maven-plugin + swagger-maven-plugin-jakarta ${swagger.version} openapi diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JaxrsApplication.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JaxrsApplication.java index 0691e26..80e422f 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JaxrsApplication.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JaxrsApplication.java @@ -1,7 +1,7 @@ package ch.schlau.pesche.apidocs.swagger.codefirst.rest; -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; import io.swagger.v3.oas.annotations.OpenAPIDefinition; import io.swagger.v3.oas.annotations.info.Info; diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonConfiguration.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonConfiguration.java index 4464ea8..2d90c36 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonConfiguration.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonConfiguration.java @@ -1,8 +1,8 @@ package ch.schlau.pesche.apidocs.swagger.codefirst.rest; -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.PanJsonAdapter; import lombok.experimental.UtilityClass; diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonContextResolver.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonContextResolver.java index 4ab43e5..ab6f55b 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonContextResolver.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/JsonContextResolver.java @@ -2,9 +2,9 @@ import static ch.schlau.pesche.apidocs.swagger.codefirst.rest.JsonConfiguration.JSONB; -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; +import jakarta.json.bind.Jsonb; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; @Provider public class JsonContextResolver implements ContextResolver { diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java index 2be4735..99df2e1 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java @@ -2,11 +2,11 @@ import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.PinCheckRequest; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.PinCheckResponse; diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTags.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTags.java index 8dc37f8..5b78e29 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTags.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTags.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model; -import javax.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/Pan.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/Pan.java index 22fdba9..2d90e58 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/Pan.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/Pan.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model; -import javax.validation.constraints.Pattern; +import jakarta.validation.constraints.Pattern; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanJsonAdapter.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanJsonAdapter.java index 8be41cc..2931ecb 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanJsonAdapter.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanJsonAdapter.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model; -import javax.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.adapter.JsonbAdapter; public class PanJsonAdapter implements JsonbAdapter { @Override diff --git a/code-first-swagger/src/main/resources/META-INF/microprofile-config.properties b/code-first-swagger/src/main/resources/META-INF/microprofile-config.properties index 8d22654..fcf1484 100644 --- a/code-first-swagger/src/main/resources/META-INF/microprofile-config.properties +++ b/code-first-swagger/src/main/resources/META-INF/microprofile-config.properties @@ -1,6 +1,10 @@ # the OpenAPI document is generated by the Swagger Maven Plugin, no annotation scan needed mp.openapi.scan.disable = true +# keep /openapi instead /q/openapi for the time being +# see https://quarkus.io/blog/path-resolution-in-quarkus/ +quarkus.http.non-application-root-path=${quarkus.http.root-path} + quarkus.log.level = DEBUG quarkus.log.console.level = INFO quarkus.log.file.enable = true diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java index 451ed7a..a3aaa39 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPincheckIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPincheckIT.java index 63110f7..f76e9eb 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPincheckIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPincheckIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPurchaseIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPurchaseIT.java index f869971..12b4620 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPurchaseIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProcPurchaseIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTagsTest.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTagsTest.java index cd61cf8..54ae16a 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTagsTest.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/EmvTagsTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanTest.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanTest.java index 17ed1be..03aab1a 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanTest.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/model/PanTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml b/code-first-swagger/src/test/resources/openapi-sorted.yaml index 9c064e5..4b33022 100644 --- a/code-first-swagger/src/test/resources/openapi-sorted.yaml +++ b/code-first-swagger/src/test/resources/openapi-sorted.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.1 +openapi: 3.0.3 info: title: txproc-code-first-swagger version: 0.9 @@ -118,3 +118,8 @@ components: - WRONG type: string type: object + securitySchemes: + SecurityScheme: + description: Authentication + scheme: basic + type: http diff --git a/code-first-swagger/src/test/resources/openapi.json b/code-first-swagger/src/test/resources/openapi.json index 9234350..13347c6 100644 --- a/code-first-swagger/src/test/resources/openapi.json +++ b/code-first-swagger/src/test/resources/openapi.json @@ -1,5 +1,5 @@ { - "openapi": "3.0.1", + "openapi": "3.0.3", "info": { "title": "txproc-code-first-swagger", "version": "0.9" @@ -165,6 +165,13 @@ } } } + }, + "securitySchemes": { + "SecurityScheme": { + "type": "http", + "description": "Authentication", + "scheme": "basic" + } } } -} +} \ No newline at end of file diff --git a/code-first-swagger/src/test/resources/openapi.yaml b/code-first-swagger/src/test/resources/openapi.yaml index 909ee58..296d8ff 100644 --- a/code-first-swagger/src/test/resources/openapi.yaml +++ b/code-first-swagger/src/test/resources/openapi.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.1 +openapi: 3.0.3 info: title: txproc-code-first-swagger version: "0.9" @@ -95,11 +95,11 @@ components: description: Collection of EMV tags type: object properties: - 84: + "84": title: Dedicated Filename description: The EMV AID as reported by ICC type: string - 9F1A: + "9F1A": description: Terminal Country Code type: string PurchaseAuthRequest: @@ -118,3 +118,8 @@ components: type: string emvTags: $ref: '#/components/schemas/EmvTags' + securitySchemes: + SecurityScheme: + type: http + description: Authentication + scheme: basic diff --git a/design-first-openapi-generator/.editorconfig b/design-first-openapi-generator/.editorconfig new file mode 100644 index 0000000..222d8e4 --- /dev/null +++ b/design-first-openapi-generator/.editorconfig @@ -0,0 +1,19 @@ +# editor configuration containing values that are different from the IntelliJ default + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space + +[*.java] +ij_java_imports_layout = $*, |, java.**, |, jakarta.**, javax.**, |, oracle.**, |, org.**, |, com.**, |, * + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_line_comment_at_first_column = false + +[{*.har,*.jsb2,*.jsb3,*.json,*.ndjson,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_indent_sequence_value = false diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index 7a7396c..cbba098 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -17,18 +17,18 @@ 11 - 1.18.10 - 1.5.0.Final + 1.18.28 + 3.2.3.Final 1.5.22 - 4.3.1 + 6.6.0 2.2 - 2.10.0 + 2.38.0 - 3.8.1 - 2.22.2 + 3.11.0 + 3.1.2 ${project.build.directory}/generated-sources/openapi @@ -46,7 +46,7 @@ - + io.quarkus quarkus-resteasy-jsonb @@ -57,11 +57,6 @@ - - com.google.code.findbugs - jsr305 - 3.0.2 - @@ -115,7 +110,7 @@ org.openapitools openapi-generator-maven-plugin - ${openapi.generator.version} + ${openapi-generator.plugin.version} @@ -135,17 +130,19 @@ true java8 native + true false . ch.schlau.pesche.apidocs.openapi.designfirst.generated.model - - hideGenerationTimestamp=true + + hideGenerationTimestamp=true + supportUrlQuery=false - - Pan=ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan - + + Pan=ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan + diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JaxrsApplication.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JaxrsApplication.java index 4e66bf3..23ce81a 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JaxrsApplication.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JaxrsApplication.java @@ -1,7 +1,7 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.rest; -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; @ApplicationPath("/api") public class JaxrsApplication extends Application { diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonConfiguration.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonConfiguration.java index 8ab3b4d..8aa2379 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonConfiguration.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonConfiguration.java @@ -1,8 +1,8 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.rest; -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; import ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.PanJsonAdapter; import lombok.experimental.UtilityClass; diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonContextResolver.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonContextResolver.java index 79cc3ba..6539144 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonContextResolver.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/JsonContextResolver.java @@ -2,9 +2,9 @@ import static ch.schlau.pesche.apidocs.openapi.designfirst.rest.JsonConfiguration.JSONB; -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; +import jakarta.json.bind.Jsonb; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; @Provider public class JsonContextResolver implements ContextResolver { diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java index a990d1e..b09cb82 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProc.java @@ -2,11 +2,11 @@ import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.EmvTags; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.PinCheckRequest; diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/Pan.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/Pan.java index f57d7c7..4874670 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/Pan.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/Pan.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model; -import javax.validation.constraints.Pattern; +import jakarta.validation.constraints.Pattern; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanJsonAdapter.java b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanJsonAdapter.java index 0bce2ab..828954a 100644 --- a/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanJsonAdapter.java +++ b/design-first-openapi-generator/src/main/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanJsonAdapter.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model; -import javax.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.adapter.JsonbAdapter; public class PanJsonAdapter implements JsonbAdapter { @Override diff --git a/design-first-openapi-generator/src/main/resources/META-INF/microprofile-config.properties b/design-first-openapi-generator/src/main/resources/META-INF/microprofile-config.properties index ac79149..fbdbd0a 100644 --- a/design-first-openapi-generator/src/main/resources/META-INF/microprofile-config.properties +++ b/design-first-openapi-generator/src/main/resources/META-INF/microprofile-config.properties @@ -1,2 +1,6 @@ # the OpenAPI document is provided as source (design-first), no annotation scan needed mp.openapi.scan.disable = true + +# keep /openapi instead /q/openapi for the time being +# see https://quarkus.io/blog/path-resolution-in-quarkus/ +quarkus.http.non-application-root-path=${quarkus.http.root-path} diff --git a/design-first-openapi-generator/src/main/resources/META-INF/openapi.yaml b/design-first-openapi-generator/src/main/resources/META-INF/openapi.yaml index f83cc5f..1fa06f6 100644 --- a/design-first-openapi-generator/src/main/resources/META-INF/openapi.yaml +++ b/design-first-openapi-generator/src/main/resources/META-INF/openapi.yaml @@ -1,9 +1,9 @@ -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-openapi version: "0.9" servers: - - url: http://localhost:8080 +- url: http://localhost:8080 paths: /api/txproc/pincheck: post: diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java index fb14de6..a18b6db 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPincheckIT.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPincheckIT.java index 221a8f7..c501135 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPincheckIT.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPincheckIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPurchaseIT.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPurchaseIT.java index acc9b4f..9d1d950 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPurchaseIT.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/rest/TxProcPurchaseIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanTest.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanTest.java index 5e28152..21b88de 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanTest.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/txproc/model/PanTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt index 16900a0..b3d7dac 100644 --- a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt +++ b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt @@ -15,23 +15,24 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; + /** * Collection of EMV tags */ -@ApiModel(description = "Collection of EMV tags") @JsonPropertyOrder({ EmvTags.JSON_PROPERTY_84, EmvTags.JSON_PROPERTY_9_F1_A }) - +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class EmvTags { public static final String JSON_PROPERTY_84 = "84"; private String _84; @@ -39,9 +40,10 @@ public class EmvTags { public static final String JSON_PROPERTY_9_F1_A = "9F1A"; private String _9F1A; + public EmvTags() { + } public EmvTags _84(String _84) { - this._84 = _84; return this; } @@ -50,8 +52,7 @@ public class EmvTags { * The EMV AID as reported by ICC * @return _84 **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "The EMV AID as reported by ICC") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_84) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -60,13 +61,14 @@ public class EmvTags { } + @JsonProperty(JSON_PROPERTY_84) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void set84(String _84) { this._84 = _84; } public EmvTags _9F1A(String _9F1A) { - this._9F1A = _9F1A; return this; } @@ -75,8 +77,7 @@ public class EmvTags { * Terminal Country Code * @return _9F1A **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Terminal Country Code") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_9_F1_A) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -85,13 +86,18 @@ public class EmvTags { } + @JsonProperty(JSON_PROPERTY_9_F1_A) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void set9F1A(String _9F1A) { this._9F1A = _9F1A; } + /** + * Return true if this EmvTags object is equal to o. + */ @Override - public boolean equals(java.lang.Object o) { + public boolean equals(Object o) { if (this == o) { return true; } @@ -108,7 +114,6 @@ public class EmvTags { return Objects.hash(_84, _9F1A); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -123,12 +128,11 @@ public class EmvTags { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(java.lang.Object o) { + private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } - } diff --git a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt index 311dcc8..0d575e0 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt @@ -15,25 +15,26 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonPropertyOrder; + /** * Request for checking a PIN */ -@ApiModel(description = "Request for checking a PIN") @JsonPropertyOrder({ PinCheckRequest.JSON_PROPERTY_PAN, PinCheckRequest.JSON_PROPERTY_PIN_BLOCK, PinCheckRequest.JSON_PROPERTY_UUID }) - +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PinCheckRequest { public static final String JSON_PROPERTY_PAN = "pan"; private ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan; @@ -44,9 +45,10 @@ public class PinCheckRequest { public static final String JSON_PROPERTY_UUID = "uuid"; private UUID uuid; + public PinCheckRequest() { + } public PinCheckRequest pan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { - this.pan = pan; return this; } @@ -55,7 +57,7 @@ public class PinCheckRequest { * Get pan * @return pan **/ - @ApiModelProperty(required = true, value = "") + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PAN) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -64,13 +66,14 @@ public class PinCheckRequest { } + @JsonProperty(JSON_PROPERTY_PAN) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setPan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; } public PinCheckRequest pinBlock(String pinBlock) { - this.pinBlock = pinBlock; return this; } @@ -79,7 +82,7 @@ public class PinCheckRequest { * Encrypted binary data containing a PIN Fieldcode: C003 * @return pinBlock **/ - @ApiModelProperty(required = true, value = "Encrypted binary data containing a PIN Fieldcode: C003") + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PIN_BLOCK) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -88,13 +91,14 @@ public class PinCheckRequest { } + @JsonProperty(JSON_PROPERTY_PIN_BLOCK) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setPinBlock(String pinBlock) { this.pinBlock = pinBlock; } public PinCheckRequest uuid(UUID uuid) { - this.uuid = uuid; return this; } @@ -103,7 +107,7 @@ public class PinCheckRequest { * Unique ID of the request * @return uuid **/ - @ApiModelProperty(required = true, value = "Unique ID of the request") + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_UUID) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -112,13 +116,18 @@ public class PinCheckRequest { } + @JsonProperty(JSON_PROPERTY_UUID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setUuid(UUID uuid) { this.uuid = uuid; } + /** + * Return true if this PinCheckRequest object is equal to o. + */ @Override - public boolean equals(java.lang.Object o) { + public boolean equals(Object o) { if (this == o) { return true; } @@ -136,7 +145,6 @@ public class PinCheckRequest { return Objects.hash(pan, pinBlock, uuid); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -152,12 +160,11 @@ public class PinCheckRequest { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(java.lang.Object o) { + private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } - } diff --git a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt index 81c5769..2d4b0ab 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt @@ -15,23 +15,24 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; + /** * Tells if the PIN in the request was correct */ -@ApiModel(description = "Tells if the PIN in the request was correct") @JsonPropertyOrder({ PinCheckResponse.JSON_PROPERTY_RESULT, PinCheckResponse.JSON_PROPERTY_TRIES }) - +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PinCheckResponse { /** * Result of the request @@ -74,9 +75,10 @@ public class PinCheckResponse { public static final String JSON_PROPERTY_TRIES = "tries"; private Integer tries; + public PinCheckResponse() { + } public PinCheckResponse result(ResultEnum result) { - this.result = result; return this; } @@ -85,8 +87,7 @@ public class PinCheckResponse { * Result of the request * @return result **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Result of the request") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -95,13 +96,14 @@ public class PinCheckResponse { } + @JsonProperty(JSON_PROPERTY_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setResult(ResultEnum result) { this.result = result; } public PinCheckResponse tries(Integer tries) { - this.tries = tries; return this; } @@ -110,8 +112,7 @@ public class PinCheckResponse { * Number of remaining tries * @return tries **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Number of remaining tries") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TRIES) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -120,13 +121,18 @@ public class PinCheckResponse { } + @JsonProperty(JSON_PROPERTY_TRIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setTries(Integer tries) { this.tries = tries; } + /** + * Return true if this PinCheckResponse object is equal to o. + */ @Override - public boolean equals(java.lang.Object o) { + public boolean equals(Object o) { if (this == o) { return true; } @@ -143,7 +149,6 @@ public class PinCheckResponse { return Objects.hash(result, tries); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -158,12 +163,11 @@ public class PinCheckResponse { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(java.lang.Object o) { + private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } - } diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt index ccd2e01..ca176cb 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt @@ -15,26 +15,27 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.EmvTags; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonPropertyOrder; + /** * Request for authorizing a Purchase */ -@ApiModel(description = "Request for authorizing a Purchase") @JsonPropertyOrder({ PurchaseAuthRequest.JSON_PROPERTY_EMV_TAGS, PurchaseAuthRequest.JSON_PROPERTY_PAN, PurchaseAuthRequest.JSON_PROPERTY_UUID }) - +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PurchaseAuthRequest { public static final String JSON_PROPERTY_EMV_TAGS = "emvTags"; private EmvTags emvTags; @@ -45,9 +46,10 @@ public class PurchaseAuthRequest { public static final String JSON_PROPERTY_UUID = "uuid"; private UUID uuid; + public PurchaseAuthRequest() { + } public PurchaseAuthRequest emvTags(EmvTags emvTags) { - this.emvTags = emvTags; return this; } @@ -56,8 +58,7 @@ public class PurchaseAuthRequest { * Get emvTags * @return emvTags **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_EMV_TAGS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -66,13 +67,14 @@ public class PurchaseAuthRequest { } + @JsonProperty(JSON_PROPERTY_EMV_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setEmvTags(EmvTags emvTags) { this.emvTags = emvTags; } public PurchaseAuthRequest pan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { - this.pan = pan; return this; } @@ -81,7 +83,7 @@ public class PurchaseAuthRequest { * Get pan * @return pan **/ - @ApiModelProperty(required = true, value = "") + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_PAN) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -90,13 +92,14 @@ public class PurchaseAuthRequest { } + @JsonProperty(JSON_PROPERTY_PAN) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setPan(ch.schlau.pesche.apidocs.openapi.designfirst.txproc.model.Pan pan) { this.pan = pan; } public PurchaseAuthRequest uuid(UUID uuid) { - this.uuid = uuid; return this; } @@ -105,7 +108,7 @@ public class PurchaseAuthRequest { * Unique ID of the request * @return uuid **/ - @ApiModelProperty(required = true, value = "Unique ID of the request") + @jakarta.annotation.Nonnull @JsonProperty(JSON_PROPERTY_UUID) @JsonInclude(value = JsonInclude.Include.ALWAYS) @@ -114,13 +117,18 @@ public class PurchaseAuthRequest { } + @JsonProperty(JSON_PROPERTY_UUID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setUuid(UUID uuid) { this.uuid = uuid; } + /** + * Return true if this PurchaseAuthRequest object is equal to o. + */ @Override - public boolean equals(java.lang.Object o) { + public boolean equals(Object o) { if (this == o) { return true; } @@ -138,7 +146,6 @@ public class PurchaseAuthRequest { return Objects.hash(emvTags, pan, uuid); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -154,12 +161,11 @@ public class PurchaseAuthRequest { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(java.lang.Object o) { + private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } - } diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt index 72a2765..5d401fa 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt @@ -15,23 +15,24 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; + /** * Response to PurchaseAuthRequest */ -@ApiModel(description = "Response to PurchaseAuthRequest") @JsonPropertyOrder({ PurchaseAuthResponse.JSON_PROPERTY_APPROVAL_CODE, PurchaseAuthResponse.JSON_PROPERTY_RESULT }) - +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PurchaseAuthResponse { public static final String JSON_PROPERTY_APPROVAL_CODE = "approvalCode"; private String approvalCode; @@ -74,9 +75,10 @@ public class PurchaseAuthResponse { public static final String JSON_PROPERTY_RESULT = "result"; private ResultEnum result; + public PurchaseAuthResponse() { + } public PurchaseAuthResponse approvalCode(String approvalCode) { - this.approvalCode = approvalCode; return this; } @@ -85,8 +87,7 @@ public class PurchaseAuthResponse { * Code referencing the successful authorization * @return approvalCode **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Code referencing the successful authorization") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_APPROVAL_CODE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -95,13 +96,14 @@ public class PurchaseAuthResponse { } + @JsonProperty(JSON_PROPERTY_APPROVAL_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setApprovalCode(String approvalCode) { this.approvalCode = approvalCode; } public PurchaseAuthResponse result(ResultEnum result) { - this.result = result; return this; } @@ -110,8 +112,7 @@ public class PurchaseAuthResponse { * Result of the request * @return result **/ - @javax.annotation.Nullable - @ApiModelProperty(value = "Result of the request") + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) @@ -120,13 +121,18 @@ public class PurchaseAuthResponse { } + @JsonProperty(JSON_PROPERTY_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public void setResult(ResultEnum result) { this.result = result; } + /** + * Return true if this PurchaseAuthResponse object is equal to o. + */ @Override - public boolean equals(java.lang.Object o) { + public boolean equals(Object o) { if (this == o) { return true; } @@ -143,7 +149,6 @@ public class PurchaseAuthResponse { return Objects.hash(approvalCode, result); } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -158,12 +163,11 @@ public class PurchaseAuthResponse { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(java.lang.Object o) { + private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } - } diff --git a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml index 155311c..3fc5fee 100644 --- a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml +++ b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-openapi version: 0.9 @@ -123,3 +123,8 @@ components: - WRONG type: string type: object + securitySchemes: + SecurityScheme: + description: Authentication + scheme: basic + type: http diff --git a/design-first-openapi-generator/src/test/resources/openapi.json b/design-first-openapi-generator/src/test/resources/openapi.json index aba034b..03b5e7f 100644 --- a/design-first-openapi-generator/src/test/resources/openapi.json +++ b/design-first-openapi-generator/src/test/resources/openapi.json @@ -1,5 +1,5 @@ { - "openapi": "3.0.0", + "openapi": "3.0.3", "info": { "title": "txproc-design-first-openapi", "version": "0.9" @@ -174,6 +174,13 @@ } } } + }, + "securitySchemes": { + "SecurityScheme": { + "type": "http", + "description": "Authentication", + "scheme": "basic" + } } } -} +} \ No newline at end of file diff --git a/design-first-openapi-generator/src/test/resources/openapi.yaml b/design-first-openapi-generator/src/test/resources/openapi.yaml index e6103c6..c126743 100644 --- a/design-first-openapi-generator/src/test/resources/openapi.yaml +++ b/design-first-openapi-generator/src/test/resources/openapi.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-openapi version: "0.9" @@ -123,3 +123,8 @@ components: - OK - WRONG type: string + securitySchemes: + SecurityScheme: + type: http + description: Authentication + scheme: basic diff --git a/design-first-swagger-quarkus/.editorconfig b/design-first-swagger-quarkus/.editorconfig new file mode 100644 index 0000000..222d8e4 --- /dev/null +++ b/design-first-swagger-quarkus/.editorconfig @@ -0,0 +1,19 @@ +# editor configuration containing values that are different from the IntelliJ default + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space + +[*.java] +ij_java_imports_layout = $*, |, java.**, |, jakarta.**, javax.**, |, oracle.**, |, org.**, |, com.**, |, * + +[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] +ij_xml_line_comment_at_first_column = false + +[{*.har,*.jsb2,*.jsb3,*.json,*.ndjson,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] +indent_size = 2 + +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_indent_sequence_value = false diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index a4cf5e6..0203de2 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -17,18 +17,18 @@ 11 - 1.18.10 - 1.5.0.Final - 2.1.2 - 3.0.20 + 1.18.28 + 3.2.3.Final + 2.2.15 + 3.0.46 2.2 - 2.10.0 + 2.38.0 - 3.8.1 - 2.22.2 + 3.11.0 + 3.1.2 ${project.build.directory}/generated-sources/swagger @@ -46,7 +46,7 @@ - + io.quarkus quarkus-resteasy-jsonb @@ -109,7 +109,7 @@ io.swagger.codegen.v3 swagger-codegen-maven-plugin - ${swagger.codegen.version} + ${swagger-codegen.plugin.version} @@ -131,12 +131,13 @@ . ch.schlau.pesche.apidocs.swagger.designfirst.generated.model - - hideGenerationTimestamp=true + + hideGenerationTimestamp=true + jakarta=true - Pan=ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan + Pan=ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java index cffd174..8d9146d 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JaxrsApplication.java @@ -1,7 +1,7 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.rest; -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; @ApplicationPath("/api") public class JaxrsApplication extends Application { diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java index 4a1acc5..8a25774 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonConfiguration.java @@ -1,8 +1,8 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.rest; -import javax.json.bind.Jsonb; -import javax.json.bind.JsonbBuilder; -import javax.json.bind.JsonbConfig; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.PanJsonAdapter; import lombok.experimental.UtilityClass; diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java index fc3df3f..ee56569 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/JsonContextResolver.java @@ -2,9 +2,9 @@ import static ch.schlau.pesche.apidocs.swagger.designfirst.rest.JsonConfiguration.JSONB; -import javax.json.bind.Jsonb; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; +import jakarta.json.bind.Jsonb; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; @Provider public class JsonContextResolver implements ContextResolver { diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java index 828df91..e7785d0 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProc.java @@ -2,11 +2,11 @@ import java.util.Optional; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.PinCheckRequest; diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java index 40637b4..784d1d0 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/Pan.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model; -import javax.validation.constraints.Pattern; +import jakarta.validation.constraints.Pattern; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java index 14f9c51..a7eadfa 100644 --- a/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java +++ b/design-first-swagger-quarkus/src/main/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanJsonAdapter.java @@ -1,6 +1,6 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model; -import javax.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.adapter.JsonbAdapter; public class PanJsonAdapter implements JsonbAdapter { @Override diff --git a/design-first-swagger-quarkus/src/main/resources/META-INF/microprofile-config.properties b/design-first-swagger-quarkus/src/main/resources/META-INF/microprofile-config.properties index ac79149..fbdbd0a 100644 --- a/design-first-swagger-quarkus/src/main/resources/META-INF/microprofile-config.properties +++ b/design-first-swagger-quarkus/src/main/resources/META-INF/microprofile-config.properties @@ -1,2 +1,6 @@ # the OpenAPI document is provided as source (design-first), no annotation scan needed mp.openapi.scan.disable = true + +# keep /openapi instead /q/openapi for the time being +# see https://quarkus.io/blog/path-resolution-in-quarkus/ +quarkus.http.non-application-root-path=${quarkus.http.root-path} diff --git a/design-first-swagger-quarkus/src/main/resources/META-INF/openapi.yaml b/design-first-swagger-quarkus/src/main/resources/META-INF/openapi.yaml index d053327..5495ed1 100644 --- a/design-first-swagger-quarkus/src/main/resources/META-INF/openapi.yaml +++ b/design-first-swagger-quarkus/src/main/resources/META-INF/openapi.yaml @@ -1,9 +1,9 @@ -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-swagger version: "0.9" servers: - - url: http://localhost:8080 +- url: http://localhost:8080 paths: /api/txproc/pincheck: post: diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java index 19259c5..33326ae 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java @@ -11,7 +11,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java index af09820..62c4942 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPincheckIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java index e7ba07c..d61caa2 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/rest/TxProcPurchaseIT.java @@ -3,7 +3,7 @@ import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; -import javax.ws.rs.core.MediaType; +import jakarta.ws.rs.core.MediaType; import org.junit.jupiter.api.Test; diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java index a4f118b..1fb5111 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/txproc/model/PanTest.java @@ -5,7 +5,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import javax.json.bind.Jsonb; +import jakarta.json.bind.Jsonb; import org.junit.jupiter.api.Test; diff --git a/design-first-swagger-quarkus/src/test/resources/EmvTags.java.txt b/design-first-swagger-quarkus/src/test/resources/EmvTags.java.txt index c9f21e7..fae201c 100644 --- a/design-first-swagger-quarkus/src/test/resources/EmvTags.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/EmvTags.java.txt @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema; */ @Schema(description = "Collection of EMV tags") + public class EmvTags { @JsonProperty("84") private String _84 = null; diff --git a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt index af54c7f..9434a97 100644 --- a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt @@ -25,6 +25,7 @@ import java.util.UUID; */ @Schema(description = "Request for checking a PIN") + public class PinCheckRequest { @JsonProperty("pan") private Pan pan = null; diff --git a/design-first-swagger-quarkus/src/test/resources/PinCheckResponse.java.txt b/design-first-swagger-quarkus/src/test/resources/PinCheckResponse.java.txt index 5e034a9..3c58f3e 100644 --- a/design-first-swagger-quarkus/src/test/resources/PinCheckResponse.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PinCheckResponse.java.txt @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema; */ @Schema(description = "Tells if the PIN in the request was correct") + public class PinCheckResponse { /** * Result of the request @@ -46,9 +47,9 @@ public class PinCheckResponse { return String.valueOf(value); } @JsonCreator - public static ResultEnum fromValue(String text) { + public static ResultEnum fromValue(String input) { for (ResultEnum b : ResultEnum.values()) { - if (String.valueOf(b.value).equals(text)) { + if (b.value.equals(input)) { return b; } } diff --git a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt index 830cca1..f33790c 100644 --- a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt @@ -26,6 +26,7 @@ import java.util.UUID; */ @Schema(description = "Request for authorizing a Purchase") + public class PurchaseAuthRequest { @JsonProperty("emvTags") private EmvTags emvTags = null; diff --git a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthResponse.java.txt b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthResponse.java.txt index 10d855a..49a52f6 100644 --- a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthResponse.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthResponse.java.txt @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.media.Schema; */ @Schema(description = "Response to PurchaseAuthRequest") + public class PurchaseAuthResponse { @JsonProperty("approvalCode") private String approvalCode = null; @@ -49,9 +50,9 @@ public class PurchaseAuthResponse { return String.valueOf(value); } @JsonCreator - public static ResultEnum fromValue(String text) { + public static ResultEnum fromValue(String input) { for (ResultEnum b : ResultEnum.values()) { - if (String.valueOf(b.value).equals(text)) { + if (b.value.equals(input)) { return b; } } diff --git a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml index 42d2069..cd019c3 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml +++ b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-swagger version: 0.9 @@ -123,3 +123,8 @@ components: - WRONG type: string type: object + securitySchemes: + SecurityScheme: + description: Authentication + scheme: basic + type: http diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.json b/design-first-swagger-quarkus/src/test/resources/openapi.json index 88e160f..55fced5 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi.json +++ b/design-first-swagger-quarkus/src/test/resources/openapi.json @@ -1,5 +1,5 @@ { - "openapi": "3.0.0", + "openapi": "3.0.3", "info": { "title": "txproc-design-first-swagger", "version": "0.9" @@ -174,6 +174,13 @@ } } } + }, + "securitySchemes": { + "SecurityScheme": { + "type": "http", + "description": "Authentication", + "scheme": "basic" + } } } } diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.yaml b/design-first-swagger-quarkus/src/test/resources/openapi.yaml index f47e3f5..503762d 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi.yaml +++ b/design-first-swagger-quarkus/src/test/resources/openapi.yaml @@ -1,5 +1,5 @@ --- -openapi: 3.0.0 +openapi: 3.0.3 info: title: txproc-design-first-swagger version: "0.9" @@ -123,3 +123,8 @@ components: - OK - WRONG type: string + securitySchemes: + SecurityScheme: + type: http + description: Authentication + scheme: basic From 87a36c49406aa36c261c613e8b53a78fff0b6a2a Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Thu, 19 Oct 2023 14:41:17 +0200 Subject: [PATCH 06/12] Replace travis with Github Actions - use the standard "Java with Maven" workflow, but with Java 11 and without uploading the dependency graph - replace the deprecated `` with `` in every pom.xml --- .github/workflows/maven.yml | 31 +++++++++++++++++++ .travis.yml | 6 ---- README.adoc | 2 +- .../.idea/runConfigurations/all__verify_.xml | 31 +++++++++++++++++++ code-first-openapi-quarkus/pom.xml | 4 +-- .../openapi/codefirst/OpenapiDocumentIT.java | 2 +- code-first-swagger/pom.xml | 4 +-- .../swagger/codefirst/OpenapiDocumentIT.java | 2 +- design-first-openapi-generator/pom.xml | 4 +-- .../designfirst/OpenapiDocumentIT.java | 2 +- design-first-swagger-quarkus/pom.xml | 4 +-- .../designfirst/OpenapiDocumentIT.java | 2 +- 12 files changed, 75 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/maven.yml delete mode 100644 .travis.yml create mode 100644 _idea/.idea/runConfigurations/all__verify_.xml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..eb83e1a --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,31 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Java CI with Maven + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -fae -B package --file pom.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8e0adbb..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: java - -# this uses Ubuntu 18.04 (Bionic Beaver) as environment, with JDK openjdk11 and maven 3.6.0 -dist: bionic - -script: mvn verify diff --git a/README.adoc b/README.adoc index f13f1b5..86f36df 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ = OpenAPI - code first or design first? -image:https://travis-ci.org/pe-st/apidocs.svg?branch=master["Build Status", link="https://travis-ci.org/pe-st/apidocs"] +image:https://github.com/pe-st/apidocs/actions/workflows/maven/badge.svg["Build Status"] == Overview diff --git a/_idea/.idea/runConfigurations/all__verify_.xml b/_idea/.idea/runConfigurations/all__verify_.xml new file mode 100644 index 0000000..48e39fd --- /dev/null +++ b/_idea/.idea/runConfigurations/all__verify_.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/code-first-openapi-quarkus/pom.xml b/code-first-openapi-quarkus/pom.xml index 84b519f..f869ccb 100755 --- a/code-first-openapi-quarkus/pom.xml +++ b/code-first-openapi-quarkus/pom.xml @@ -120,9 +120,9 @@ maven-surefire-plugin ${maven.surefire.plugin.version} - + org.jboss.logmanager.LogManager - + **/*Test.java diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java index 8aac12e..eae9a48 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java @@ -72,7 +72,7 @@ void openapi_json() throws IOException { .assertThat().contentType(MediaType.APPLICATION_JSON) .extract().response().asString(); - assertThat(document, jsonEquals(expected)); + assertThat("actual: " + document, document, jsonEquals(expected)); } private String sortYaml(String yaml) throws IOException { diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 4b4686c..30ed0ac 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -149,9 +149,9 @@ maven-surefire-plugin ${maven.surefire.plugin.version} - + org.jboss.logmanager.LogManager - + **/*Test.java diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java index a3aaa39..13e3711 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java @@ -73,7 +73,7 @@ void openapi_json() throws IOException { .assertThat().contentType(MediaType.APPLICATION_JSON) .extract().response().asString(); - assertThat(document, jsonEquals(expected)); + assertThat("actual: " + document, document, jsonEquals(expected)); } private String sortYaml(String yaml) throws IOException { diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index cbba098..a560884 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -173,10 +173,10 @@ maven-surefire-plugin ${maven.surefire.plugin.version} - + org.jboss.logmanager.LogManager ${generated.path} - + **/*Test.java diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java index a18b6db..9a3c621 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java @@ -72,7 +72,7 @@ void openapi_json() throws IOException { .assertThat().contentType(MediaType.APPLICATION_JSON) .extract().response().asString(); - assertThat(document, jsonEquals(expected)); + assertThat("actual: " + document, document, jsonEquals(expected)); } private String sortYaml(String yaml) throws IOException { diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index 0203de2..dcf9100 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -169,10 +169,10 @@ maven-surefire-plugin ${maven.surefire.plugin.version} - + org.jboss.logmanager.LogManager ${generated.path} - + **/*Test.java diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java index 33326ae..0192592 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java @@ -72,7 +72,7 @@ void openapi_json() throws IOException { .assertThat().contentType(MediaType.APPLICATION_JSON) .extract().response().asString(); - assertThat(document, jsonEquals(expected)); + assertThat("actual: " + document, document, jsonEquals(expected)); } private String sortYaml(String yaml) throws IOException { From efe057682d40fec6f9ac483d4e89d8a410bcbd95 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Thu, 19 Oct 2023 17:59:30 +0200 Subject: [PATCH 07/12] Upgrade to Java 17, Quarkus 3.4, generator 7.0.1 --- .github/workflows/maven.yml | 10 +- README.adoc | 4 +- _idea/.idea/encodings.xml | 4 + _idea/.idea/misc.xml | 3 +- code-first-openapi-quarkus/pom.xml | 15 +- .../src/test/resources/openapi.json | 287 ++++++++---------- code-first-swagger/pom.xml | 8 +- design-first-openapi-generator/pom.xml | 13 +- .../src/test/resources/EmvTags.java.txt | 2 +- .../test/resources/PinCheckRequest.java.txt | 2 +- .../test/resources/PinCheckResponse.java.txt | 2 +- .../resources/PurchaseAuthRequest.java.txt | 2 +- .../resources/PurchaseAuthResponse.java.txt | 2 +- design-first-swagger-quarkus/pom.xml | 12 +- .../test/resources/PinCheckRequest.java.txt | 9 +- .../resources/PurchaseAuthRequest.java.txt | 9 +- 16 files changed, 186 insertions(+), 198 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index eb83e1a..c9834fa 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -20,12 +20,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up JDK 11 + - uses: actions/checkout@v4 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' + java-version: '17' distribution: 'temurin' cache: maven - name: Build with Maven - run: mvn -fae -B package --file pom.xml + run: | + mvn -v + mvn -B package --file pom.xml diff --git a/README.adoc b/README.adoc index 86f36df..0746086 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ = OpenAPI - code first or design first? -image:https://github.com/pe-st/apidocs/actions/workflows/maven/badge.svg["Build Status"] +image:https://github.com/pe-st/apidocs/actions/workflows/maven/badge.svg?branch=feature%2Fupdates["Build Status"] == Overview @@ -17,7 +17,7 @@ Accompanying presentation at https://www.eclipsecon.org/europe2019[eclipsecon Eu https://www.eclipsecon.org/europe2019/sessions/microprofile-openapi-code-first-or-design-first[MicroProfile OpenAPI - code first or design first?] The examples use https://quarkus.io/[Quarkus] as server -just because it not only support MicroProfile OpenAPI, but comes also with an integrated UI. +just because it not only supports MicroProfile OpenAPI, but comes also with an integrated UI. But the examples should run with very few code changes in any MicroProfile compatible server. === Code First diff --git a/_idea/.idea/encodings.xml b/_idea/.idea/encodings.xml index cbbfe30..435c934 100644 --- a/_idea/.idea/encodings.xml +++ b/_idea/.idea/encodings.xml @@ -4,15 +4,19 @@ + + + + diff --git a/_idea/.idea/misc.xml b/_idea/.idea/misc.xml index 1eb41e7..93e7c1e 100644 --- a/_idea/.idea/misc.xml +++ b/_idea/.idea/misc.xml @@ -1,3 +1,4 @@ + @@ -153,7 +154,7 @@ - + \ No newline at end of file diff --git a/code-first-openapi-quarkus/pom.xml b/code-first-openapi-quarkus/pom.xml index f869ccb..c387ab5 100755 --- a/code-first-openapi-quarkus/pom.xml +++ b/code-first-openapi-quarkus/pom.xml @@ -14,15 +14,15 @@ - 11 + 17 - 1.18.28 - 3.2.3.Final + 1.18.30 + 3.4.3 2.2 - 2.38.0 + 3.2.2 3.11.0 @@ -60,6 +60,13 @@ provided + + + io.quarkus + quarkus-smallrye-openapi-deployment + test + + io.quarkus diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json b/code-first-openapi-quarkus/src/test/resources/openapi.json index 8404477..49405de 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json @@ -1,34 +1,32 @@ { - "openapi": "3.0.3", - "info": { - "title": "txproc-code-first-openapi", - "version": "0.9" + "openapi" : "3.0.3", + "info" : { + "title" : "txproc-code-first-openapi", + "version" : "0.9" }, - "paths": { - "/api/txproc/pincheck": { - "post": { - "tags": [ - "Tx Proc" - ], - "summary": "Check the pin", - "requestBody": { - "description": "PIN Check Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" + "paths" : { + "/api/txproc/pincheck" : { + "post" : { + "tags" : [ "Tx Proc" ], + "summary" : "Check the pin", + "requestBody" : { + "description" : "PIN Check Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "PIN Check Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" + "responses" : { + "default" : { + "description" : "PIN Check Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckResponse" } } } @@ -36,30 +34,28 @@ } } }, - "/api/txproc/purchase": { - "post": { - "tags": [ - "Tx Proc" - ], - "summary": "Authorize a Purchase", - "requestBody": { - "description": "Purchase Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" + "/api/txproc/purchase" : { + "post" : { + "tags" : [ "Tx Proc" ], + "summary" : "Authorize a Purchase", + "requestBody" : { + "description" : "Purchase Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "Purchase Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" + "responses" : { + "default" : { + "description" : "Purchase Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthResponse" } } } @@ -68,144 +64,123 @@ } } }, - "components": { - "schemas": { - "Code": { - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "components" : { + "schemas" : { + "Code" : { + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "Code1": { - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "Code1" : { + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "EmvTags": { - "title": "EmvTags", - "description": "Collection of EMV tags", - "type": "object", - "properties": { - "84": { - "title": "Dedicated Filename", - "description": "The EMV AID as reported by ICC", - "type": "string" + "EmvTags" : { + "title" : "EmvTags", + "description" : "Collection of EMV tags", + "type" : "object", + "properties" : { + "84" : { + "title" : "Dedicated Filename", + "description" : "The EMV AID as reported by ICC", + "type" : "string" }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" + "9F1A" : { + "description" : "Terminal Country Code", + "type" : "string" } } }, - "Pan": { - "$ref": "#/components/schemas/Pan" + "Pan" : { + "$ref" : "#/components/schemas/Pan" }, - "PinCheckRequest": { - "description": "Request for checking a PIN", - "required": [ - "uuid", - "pan", - "pinBlock" - ], - "type": "object", - "properties": { - "uuid": { - "description": "Unique ID of the request", - "type": "string", - "allOf": [ - { - "$ref": "#/components/schemas/UUID" - } - ] + "PinCheckRequest" : { + "description" : "Request for checking a PIN", + "required" : [ "uuid", "pan", "pinBlock" ], + "type" : "object", + "properties" : { + "uuid" : { + "description" : "Unique ID of the request", + "type" : "string", + "allOf" : [ { + "$ref" : "#/components/schemas/UUID" + } ] }, - "pan": { - "$ref": "#/components/schemas/Pan" + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" + "pinBlock" : { + "description" : "Encrypted binary data containing a PIN\n\nFieldcode: C003", + "type" : "string" } } }, - "PinCheckResponse": { - "description": "Tells if the PIN in the request was correct", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "type": "string", - "allOf": [ - { - "$ref": "#/components/schemas/Code1" - } - ] + "PinCheckResponse" : { + "description" : "Tells if the PIN in the request was correct", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "type" : "string", + "allOf" : [ { + "$ref" : "#/components/schemas/Code1" + } ] }, - "tries": { - "format": "int32", - "description": "Number of remaining tries", - "type": "integer" + "tries" : { + "format" : "int32", + "description" : "Number of remaining tries", + "type" : "integer" } } }, - "PurchaseAuthRequest": { - "description": "Request for authorizing a Purchase", - "required": [ - "uuid", - "pan" - ], - "type": "object", - "properties": { - "uuid": { - "description": "Unique ID of the request", - "type": "string", - "allOf": [ - { - "$ref": "#/components/schemas/UUID" - } - ] + "PurchaseAuthRequest" : { + "description" : "Request for authorizing a Purchase", + "required" : [ "uuid", "pan" ], + "type" : "object", + "properties" : { + "uuid" : { + "description" : "Unique ID of the request", + "type" : "string", + "allOf" : [ { + "$ref" : "#/components/schemas/UUID" + } ] }, - "pan": { - "$ref": "#/components/schemas/Pan" + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "emvTags": { - "$ref": "#/components/schemas/EmvTags" + "emvTags" : { + "$ref" : "#/components/schemas/EmvTags" } } }, - "PurchaseAuthResponse": { - "description": "Response to PurchaseAuthRequest", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "type": "string", - "allOf": [ - { - "$ref": "#/components/schemas/Code" - } - ] + "PurchaseAuthResponse" : { + "description" : "Response to PurchaseAuthRequest", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "type" : "string", + "allOf" : [ { + "$ref" : "#/components/schemas/Code" + } ] }, - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" + "approvalCode" : { + "description" : "Code referencing the successful authorization", + "type" : "string" } } }, - "UUID": { - "format": "uuid", - "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", - "type": "string" + "UUID" : { + "format" : "uuid", + "pattern" : "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", + "type" : "string" } }, - "securitySchemes": { - "SecurityScheme": { - "type": "http", - "description": "Authentication", - "scheme": "basic" + "securitySchemes" : { + "SecurityScheme" : { + "type" : "http", + "description" : "Authentication", + "scheme" : "basic" } } } -} \ No newline at end of file +} diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 30ed0ac..9a3c956 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -14,16 +14,16 @@ - 11 + 17 - 1.18.28 - 3.2.3.Final + 1.18.30 + 3.4.3 2.2.15 2.2 - 2.38.0 + 3.2.2 3.11.0 diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index a560884..22237e0 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -14,17 +14,17 @@ - 11 + 17 - 1.18.28 - 3.2.3.Final - 1.5.22 - 6.6.0 + 1.18.30 + 3.4.3 + 1.6.12 + 7.0.1 2.2 - 2.38.0 + 3.2.2 3.11.0 @@ -59,6 +59,7 @@ + io.swagger swagger-annotations diff --git a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt index b3d7dac..67b962c 100644 --- a/design-first-openapi-generator/src/test/resources/EmvTags.java.txt +++ b/design-first-openapi-generator/src/test/resources/EmvTags.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; -import java.util.Arrays; import java.util.Map; import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt index 0d575e0..0c05ad1 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckRequest.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; -import java.util.Arrays; import java.util.Map; import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt index 2d4b0ab..0070dee 100644 --- a/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PinCheckResponse.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; -import java.util.Arrays; import java.util.Map; import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt index ca176cb..8c29d9a 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthRequest.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; -import java.util.Arrays; import java.util.Map; import java.util.HashMap; import ch.schlau.pesche.apidocs.openapi.designfirst.generated.model.EmvTags; @@ -23,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt index 5d401fa..f19953e 100644 --- a/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt +++ b/design-first-openapi-generator/src/test/resources/PurchaseAuthResponse.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.openapi.designfirst.generated.model; import java.util.Objects; -import java.util.Arrays; import java.util.Map; import java.util.HashMap; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Arrays; import com.fasterxml.jackson.annotation.JsonPropertyOrder; diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index dcf9100..3da586c 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -14,17 +14,17 @@ - 11 + 17 - 1.18.28 - 3.2.3.Final - 2.2.15 - 3.0.46 + 1.18.30 + 3.4.3 + 2.2.16 + 3.0.47 2.2 - 2.38.0 + 3.2.2 3.11.0 diff --git a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt index 9434a97..f779ac5 100644 --- a/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PinCheckRequest.java.txt @@ -14,7 +14,6 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -28,7 +27,7 @@ import java.util.UUID; public class PinCheckRequest { @JsonProperty("pan") - private Pan pan = null; + private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; @JsonProperty("pinBlock") private String pinBlock = null; @@ -36,7 +35,7 @@ public class PinCheckRequest { @JsonProperty("uuid") private UUID uuid = null; - public PinCheckRequest pan(Pan pan) { + public PinCheckRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { this.pan = pan; return this; } @@ -46,11 +45,11 @@ public class PinCheckRequest { * @return pan **/ @Schema(required = true, description = "") - public Pan getPan() { + public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { return pan; } - public void setPan(Pan pan) { + public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { this.pan = pan; } diff --git a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt index f33790c..a355728 100644 --- a/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt +++ b/design-first-swagger-quarkus/src/test/resources/PurchaseAuthRequest.java.txt @@ -15,7 +15,6 @@ package ch.schlau.pesche.apidocs.swagger.designfirst.generated.model; import java.util.Objects; import java.util.Arrays; import ch.schlau.pesche.apidocs.swagger.designfirst.generated.model.EmvTags; -import ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; @@ -32,7 +31,7 @@ public class PurchaseAuthRequest { private EmvTags emvTags = null; @JsonProperty("pan") - private Pan pan = null; + private ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan = null; @JsonProperty("uuid") private UUID uuid = null; @@ -55,7 +54,7 @@ public class PurchaseAuthRequest { this.emvTags = emvTags; } - public PurchaseAuthRequest pan(Pan pan) { + public PurchaseAuthRequest pan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { this.pan = pan; return this; } @@ -65,11 +64,11 @@ public class PurchaseAuthRequest { * @return pan **/ @Schema(required = true, description = "") - public Pan getPan() { + public ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan getPan() { return pan; } - public void setPan(Pan pan) { + public void setPan(ch.schlau.pesche.apidocs.swagger.designfirst.txproc.model.Pan pan) { this.pan = pan; } From 679e9e10121ba8357ed82d4288cd5269b68c1365 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Tue, 31 Oct 2023 20:04:08 +0100 Subject: [PATCH 08/12] Rename reference files to .txt - no IDE refactoring for txt files --- .../pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java | 6 +++--- .../{openapi-sorted.yaml => openapi-sorted.yaml.txt} | 0 .../src/test/resources/{openapi.json => openapi.json.txt} | 0 .../src/test/resources/{openapi.yaml => openapi.yaml.txt} | 0 .../pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java | 6 +++--- .../{openapi-sorted.yaml => openapi-sorted.yaml.txt} | 0 .../src/test/resources/{openapi.json => openapi.json.txt} | 0 .../src/test/resources/{openapi.yaml => openapi.yaml.txt} | 0 .../apidocs/openapi/designfirst/OpenapiDocumentIT.java | 6 +++--- .../{openapi-sorted.yaml => openapi-sorted.yaml.txt} | 0 .../src/test/resources/{openapi.json => openapi.json.txt} | 0 .../src/test/resources/{openapi.yaml => openapi.yaml.txt} | 0 .../apidocs/swagger/designfirst/OpenapiDocumentIT.java | 6 +++--- .../{openapi-sorted.yaml => openapi-sorted.yaml.txt} | 0 .../src/test/resources/{openapi.json => openapi.json.txt} | 0 .../src/test/resources/{openapi.yaml => openapi.yaml.txt} | 0 16 files changed, 12 insertions(+), 12 deletions(-) rename code-first-openapi-quarkus/src/test/resources/{openapi-sorted.yaml => openapi-sorted.yaml.txt} (100%) rename code-first-openapi-quarkus/src/test/resources/{openapi.json => openapi.json.txt} (100%) rename code-first-openapi-quarkus/src/test/resources/{openapi.yaml => openapi.yaml.txt} (100%) rename code-first-swagger/src/test/resources/{openapi-sorted.yaml => openapi-sorted.yaml.txt} (100%) rename code-first-swagger/src/test/resources/{openapi.json => openapi.json.txt} (100%) rename code-first-swagger/src/test/resources/{openapi.yaml => openapi.yaml.txt} (100%) rename design-first-openapi-generator/src/test/resources/{openapi-sorted.yaml => openapi-sorted.yaml.txt} (100%) rename design-first-openapi-generator/src/test/resources/{openapi.json => openapi.json.txt} (100%) rename design-first-openapi-generator/src/test/resources/{openapi.yaml => openapi.yaml.txt} (100%) rename design-first-swagger-quarkus/src/test/resources/{openapi-sorted.yaml => openapi-sorted.yaml.txt} (100%) rename design-first-swagger-quarkus/src/test/resources/{openapi.json => openapi.json.txt} (100%) rename design-first-swagger-quarkus/src/test/resources/{openapi.yaml => openapi.yaml.txt} (100%) diff --git a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java index eae9a48..c2b646b 100644 --- a/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java +++ b/code-first-openapi-quarkus/src/test/java/ch/schlau/pesche/apidocs/openapi/codefirst/OpenapiDocumentIT.java @@ -44,8 +44,8 @@ static class OpenapiSkeleton { @Test void openapi_yaml() throws IOException { - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); + String expected = loadResourceFile("openapi.yaml.txt"); + String expectedSorted = loadResourceFile("openapi-sorted.yaml.txt"); String document = when().get("/openapi") .then() @@ -63,7 +63,7 @@ void openapi_yaml() throws IOException { @Test void openapi_json() throws IOException { - String expected = loadResourceFile("openapi.json"); + String expected = loadResourceFile("openapi.json.txt"); String document = given().accept(MediaType.APPLICATION_JSON) .when().get("/openapi") diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt similarity index 100% rename from code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml rename to code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt similarity index 100% rename from code-first-openapi-quarkus/src/test/resources/openapi.json rename to code-first-openapi-quarkus/src/test/resources/openapi.json.txt diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt similarity index 100% rename from code-first-openapi-quarkus/src/test/resources/openapi.yaml rename to code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java index 13e3711..d9a7569 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java @@ -44,8 +44,8 @@ static class OpenapiSkeleton { @Test void openapi_yaml() throws IOException { - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); + String expected = loadResourceFile("openapi.yaml.txt"); + String expectedSorted = loadResourceFile("openapi-sorted.yaml.txt"); String document = when().get("/openapi") .then() @@ -64,7 +64,7 @@ void openapi_yaml() throws IOException { @Test void openapi_json() throws IOException { - String expected = loadResourceFile("openapi.json"); + String expected = loadResourceFile("openapi.json.txt"); String document = given().accept(MediaType.APPLICATION_JSON) .when().get("/openapi") diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt similarity index 100% rename from code-first-swagger/src/test/resources/openapi-sorted.yaml rename to code-first-swagger/src/test/resources/openapi-sorted.yaml.txt diff --git a/code-first-swagger/src/test/resources/openapi.json b/code-first-swagger/src/test/resources/openapi.json.txt similarity index 100% rename from code-first-swagger/src/test/resources/openapi.json rename to code-first-swagger/src/test/resources/openapi.json.txt diff --git a/code-first-swagger/src/test/resources/openapi.yaml b/code-first-swagger/src/test/resources/openapi.yaml.txt similarity index 100% rename from code-first-swagger/src/test/resources/openapi.yaml rename to code-first-swagger/src/test/resources/openapi.yaml.txt diff --git a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java index 9a3c621..00fb605 100644 --- a/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java +++ b/design-first-openapi-generator/src/test/java/ch/schlau/pesche/apidocs/openapi/designfirst/OpenapiDocumentIT.java @@ -44,8 +44,8 @@ static class OpenapiSkeleton { @Test void openapi_yaml() throws IOException { - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); + String expected = loadResourceFile("openapi.yaml.txt"); + String expectedSorted = loadResourceFile("openapi-sorted.yaml.txt"); String document = when().get("/openapi") .then() @@ -63,7 +63,7 @@ void openapi_yaml() throws IOException { @Test void openapi_json() throws IOException { - String expected = loadResourceFile("openapi.json"); + String expected = loadResourceFile("openapi.json.txt"); String document = given().accept(MediaType.APPLICATION_JSON) .when().get("/openapi") diff --git a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt similarity index 100% rename from design-first-openapi-generator/src/test/resources/openapi-sorted.yaml rename to design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt diff --git a/design-first-openapi-generator/src/test/resources/openapi.json b/design-first-openapi-generator/src/test/resources/openapi.json.txt similarity index 100% rename from design-first-openapi-generator/src/test/resources/openapi.json rename to design-first-openapi-generator/src/test/resources/openapi.json.txt diff --git a/design-first-openapi-generator/src/test/resources/openapi.yaml b/design-first-openapi-generator/src/test/resources/openapi.yaml.txt similarity index 100% rename from design-first-openapi-generator/src/test/resources/openapi.yaml rename to design-first-openapi-generator/src/test/resources/openapi.yaml.txt diff --git a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java index 0192592..3e1573b 100644 --- a/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java +++ b/design-first-swagger-quarkus/src/test/java/ch/schlau/pesche/apidocs/swagger/designfirst/OpenapiDocumentIT.java @@ -44,8 +44,8 @@ static class OpenapiSkeleton { @Test void openapi_yaml() throws IOException { - String expected = loadResourceFile("openapi.yaml"); - String expectedSorted = loadResourceFile("openapi-sorted.yaml"); + String expected = loadResourceFile("openapi.yaml.txt"); + String expectedSorted = loadResourceFile("openapi-sorted.yaml.txt"); String document = when().get("/openapi") .then() @@ -63,7 +63,7 @@ void openapi_yaml() throws IOException { @Test void openapi_json() throws IOException { - String expected = loadResourceFile("openapi.json"); + String expected = loadResourceFile("openapi.json.txt"); String document = given().accept(MediaType.APPLICATION_JSON) .when().get("/openapi") diff --git a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt similarity index 100% rename from design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml rename to design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.json b/design-first-swagger-quarkus/src/test/resources/openapi.json.txt similarity index 100% rename from design-first-swagger-quarkus/src/test/resources/openapi.json rename to design-first-swagger-quarkus/src/test/resources/openapi.json.txt diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.yaml b/design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt similarity index 100% rename from design-first-swagger-quarkus/src/test/resources/openapi.yaml rename to design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt From 467c63bc803b2e54efdd06014bf2ef07427ab8b6 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Tue, 31 Oct 2023 20:25:40 +0100 Subject: [PATCH 09/12] Upgrade Quarkus 3.5 and test with Java 21 --- .github/workflows/maven.yml | 10 +- _idea/.idea/misc.xml | 3 +- code-first-openapi-quarkus/pom.xml | 25 +- .../test/resources/openapi-sorted.yaml.txt | 13 +- .../src/test/resources/openapi.json.txt | 15 +- .../src/test/resources/openapi.yaml.txt | 13 +- code-first-swagger/pom.xml | 20 +- .../test/resources/openapi-sorted.yaml.txt | 5 - .../src/test/resources/openapi.json.txt | 234 ++++++++-------- .../src/test/resources/openapi.yaml.txt | 5 - design-first-openapi-generator/pom.xml | 18 +- .../test/resources/openapi-sorted.yaml.txt | 5 - .../src/test/resources/openapi.json.txt | 250 ++++++++---------- .../src/test/resources/openapi.yaml.txt | 5 - design-first-swagger-quarkus/pom.xml | 22 +- .../test/resources/openapi-sorted.yaml.txt | 5 - .../src/test/resources/openapi.json.txt | 248 ++++++++--------- .../src/test/resources/openapi.yaml.txt | 5 - 18 files changed, 424 insertions(+), 477 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c9834fa..fff59aa 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -16,16 +16,18 @@ on: jobs: build: - runs-on: ubuntu-latest - + strategy: + matrix: + java: [ '17', '21' ] + name: Build with Java ${{ matrix.Java }} steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: '17' distribution: 'temurin' + java-version: ${{ matrix.java }} cache: maven - name: Build with Maven run: | diff --git a/_idea/.idea/misc.xml b/_idea/.idea/misc.xml index 93e7c1e..26df1c0 100644 --- a/_idea/.idea/misc.xml +++ b/_idea/.idea/misc.xml @@ -101,6 +101,7 @@ + - - - io.quarkus - quarkus-smallrye-openapi-deployment - test - - io.quarkus @@ -97,6 +90,13 @@ ${json.unit.version} test + + + + io.quarkus + quarkus-smallrye-openapi-deployment + test + @@ -120,6 +120,13 @@ ${java.release} + + + org.projectlombok + lombok + ${lombok.version} + + diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt index 0dc1c08..1f2f066 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt @@ -67,7 +67,9 @@ components: title: EmvTags type: object Pan: - $ref: '#/components/schemas/Pan' + description: The number embossed on credit cards + title: PAN (Primary Account Number) + type: string PinCheckRequest: description: Request for checking a PIN properties: @@ -94,7 +96,7 @@ components: properties: result: allOf: - - $ref: '#/components/schemas/Code1' + - $ref: '#/components/schemas/Code' description: Result of the request type: string tries: @@ -126,7 +128,7 @@ components: type: string result: allOf: - - $ref: '#/components/schemas/Code' + - $ref: '#/components/schemas/Code1' description: Result of the request type: string type: object @@ -134,8 +136,3 @@ components: format: uuid pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" type: string - securitySchemes: - SecurityScheme: - description: Authentication - scheme: basic - type: http diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt index 49405de..fa24cf1 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt @@ -91,7 +91,9 @@ } }, "Pan" : { - "$ref" : "#/components/schemas/Pan" + "title" : "PAN (Primary Account Number)", + "description" : "The number embossed on credit cards", + "type" : "string" }, "PinCheckRequest" : { "description" : "Request for checking a PIN", @@ -122,7 +124,7 @@ "description" : "Result of the request", "type" : "string", "allOf" : [ { - "$ref" : "#/components/schemas/Code1" + "$ref" : "#/components/schemas/Code" } ] }, "tries" : { @@ -160,7 +162,7 @@ "description" : "Result of the request", "type" : "string", "allOf" : [ { - "$ref" : "#/components/schemas/Code" + "$ref" : "#/components/schemas/Code1" } ] }, "approvalCode" : { @@ -174,13 +176,6 @@ "pattern" : "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", "type" : "string" } - }, - "securitySchemes" : { - "SecurityScheme" : { - "type" : "http", - "description" : "Authentication", - "scheme" : "basic" - } } } } diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt index 626459b..020eddb 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt @@ -67,7 +67,9 @@ components: description: Terminal Country Code type: string Pan: - $ref: '#/components/schemas/Pan' + title: PAN (Primary Account Number) + description: The number embossed on credit cards + type: string PinCheckRequest: description: Request for checking a PIN required: @@ -97,7 +99,7 @@ components: description: Result of the request type: string allOf: - - $ref: '#/components/schemas/Code1' + - $ref: '#/components/schemas/Code' tries: format: int32 description: Number of remaining tries @@ -126,7 +128,7 @@ components: description: Result of the request type: string allOf: - - $ref: '#/components/schemas/Code' + - $ref: '#/components/schemas/Code1' approvalCode: description: Code referencing the successful authorization type: string @@ -134,8 +136,3 @@ components: format: uuid pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}" type: string - securitySchemes: - SecurityScheme: - type: http - description: Authentication - scheme: basic diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 9a3c956..9fd6ff1 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -18,8 +18,8 @@ 1.18.30 - 3.4.3 - 2.2.15 + 3.5.0 + 2.2.18 2.2 @@ -27,7 +27,7 @@ 3.11.0 - 3.1.2 + 3.2.1 @@ -96,6 +96,13 @@ ${json.unit.version} test + + + + io.quarkus + quarkus-smallrye-openapi-deployment + test + @@ -142,6 +149,13 @@ ${java.release} + + + org.projectlombok + lombok + ${lombok.version} + + diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt index 4b33022..65b3bc2 100644 --- a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt @@ -118,8 +118,3 @@ components: - WRONG type: string type: object - securitySchemes: - SecurityScheme: - description: Authentication - scheme: basic - type: http diff --git a/code-first-swagger/src/test/resources/openapi.json.txt b/code-first-swagger/src/test/resources/openapi.json.txt index 13347c6..bf912d8 100644 --- a/code-first-swagger/src/test/resources/openapi.json.txt +++ b/code-first-swagger/src/test/resources/openapi.json.txt @@ -1,32 +1,32 @@ { - "openapi": "3.0.3", - "info": { - "title": "txproc-code-first-swagger", - "version": "0.9" + "openapi" : "3.0.3", + "info" : { + "title" : "txproc-code-first-swagger", + "version" : "0.9" }, - "paths": { - "/txproc/pincheck": { - "post": { - "summary": "Check the pin", - "operationId": "pinCheck", - "requestBody": { - "description": "PIN Check Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" + "paths" : { + "/txproc/pincheck" : { + "post" : { + "summary" : "Check the pin", + "operationId" : "pinCheck", + "requestBody" : { + "description" : "PIN Check Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "PIN Check Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" + "responses" : { + "default" : { + "description" : "PIN Check Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckResponse" } } } @@ -34,28 +34,28 @@ } } }, - "/txproc/purchase": { - "post": { - "summary": "Authorize a Purchase", - "operationId": "purchase", - "requestBody": { - "description": "Purchase Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" + "/txproc/purchase" : { + "post" : { + "summary" : "Authorize a Purchase", + "operationId" : "purchase", + "requestBody" : { + "description" : "Purchase Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "Purchase Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" + "responses" : { + "default" : { + "description" : "Purchase Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthResponse" } } } @@ -64,114 +64,94 @@ } } }, - "components": { - "schemas": { - "PinCheckResponse": { - "description": "Tells if the PIN in the request was correct", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "components" : { + "schemas" : { + "PinCheckResponse" : { + "description" : "Tells if the PIN in the request was correct", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "tries": { - "format": "int32", - "description": "Number of remaining tries", - "type": "integer" + "tries" : { + "format" : "int32", + "description" : "Number of remaining tries", + "type" : "integer" } } }, - "PinCheckRequest": { - "description": "Request for checking a PIN", - "required": [ - "pan", - "pinBlock", - "uuid" - ], - "type": "object", - "properties": { - "uuid": { - "description": "Unique ID of the request", - "type": "string" + "PinCheckRequest" : { + "description" : "Request for checking a PIN", + "required" : [ "pan", "pinBlock", "uuid" ], + "type" : "object", + "properties" : { + "uuid" : { + "description" : "Unique ID of the request", + "type" : "string" }, - "pan": { - "title": "PAN (Primary Account Number)", - "description": "The number embossed on credit cards", - "type": "string" + "pan" : { + "title" : "PAN (Primary Account Number)", + "description" : "The number embossed on credit cards", + "type" : "string" }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" + "pinBlock" : { + "description" : "Encrypted binary data containing a PIN\n\nFieldcode: C003", + "type" : "string" } } }, - "PurchaseAuthResponse": { - "description": "Response to PurchaseAuthRequest", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "PurchaseAuthResponse" : { + "description" : "Response to PurchaseAuthRequest", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" + "approvalCode" : { + "description" : "Code referencing the successful authorization", + "type" : "string" } } }, - "EmvTags": { - "title": "EmvTags", - "description": "Collection of EMV tags", - "type": "object", - "properties": { - "84": { - "title": "Dedicated Filename", - "description": "The EMV AID as reported by ICC", - "type": "string" + "EmvTags" : { + "title" : "EmvTags", + "description" : "Collection of EMV tags", + "type" : "object", + "properties" : { + "84" : { + "title" : "Dedicated Filename", + "description" : "The EMV AID as reported by ICC", + "type" : "string" }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" + "9F1A" : { + "description" : "Terminal Country Code", + "type" : "string" } } }, - "PurchaseAuthRequest": { - "description": "Request for authorizing a Purchase", - "required": [ - "pan", - "uuid" - ], - "type": "object", - "properties": { - "uuid": { - "description": "Unique ID of the request", - "type": "string" + "PurchaseAuthRequest" : { + "description" : "Request for authorizing a Purchase", + "required" : [ "pan", "uuid" ], + "type" : "object", + "properties" : { + "uuid" : { + "description" : "Unique ID of the request", + "type" : "string" }, - "pan": { - "title": "PAN (Primary Account Number)", - "description": "The number embossed on credit cards", - "type": "string" + "pan" : { + "title" : "PAN (Primary Account Number)", + "description" : "The number embossed on credit cards", + "type" : "string" }, - "emvTags": { - "$ref": "#/components/schemas/EmvTags" + "emvTags" : { + "$ref" : "#/components/schemas/EmvTags" } } } - }, - "securitySchemes": { - "SecurityScheme": { - "type": "http", - "description": "Authentication", - "scheme": "basic" - } } } } \ No newline at end of file diff --git a/code-first-swagger/src/test/resources/openapi.yaml.txt b/code-first-swagger/src/test/resources/openapi.yaml.txt index 296d8ff..412e941 100644 --- a/code-first-swagger/src/test/resources/openapi.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi.yaml.txt @@ -118,8 +118,3 @@ components: type: string emvTags: $ref: '#/components/schemas/EmvTags' - securitySchemes: - SecurityScheme: - type: http - description: Authentication - scheme: basic diff --git a/design-first-openapi-generator/pom.xml b/design-first-openapi-generator/pom.xml index 22237e0..8d11afb 100644 --- a/design-first-openapi-generator/pom.xml +++ b/design-first-openapi-generator/pom.xml @@ -18,7 +18,7 @@ 1.18.30 - 3.4.3 + 3.5.0 1.6.12 7.0.1 @@ -28,7 +28,7 @@ 3.11.0 - 3.1.2 + 3.2.1 ${project.build.directory}/generated-sources/openapi @@ -104,6 +104,13 @@ ${json.unit.version} test + + + + io.quarkus + quarkus-smallrye-openapi-deployment + test + @@ -167,6 +174,13 @@ ${java.release} + + + org.projectlombok + lombok + ${lombok.version} + + diff --git a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt index 3fc5fee..4795495 100644 --- a/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt +++ b/design-first-openapi-generator/src/test/resources/openapi-sorted.yaml.txt @@ -123,8 +123,3 @@ components: - WRONG type: string type: object - securitySchemes: - SecurityScheme: - description: Authentication - scheme: basic - type: http diff --git a/design-first-openapi-generator/src/test/resources/openapi.json.txt b/design-first-openapi-generator/src/test/resources/openapi.json.txt index 03b5e7f..cd4e4d0 100644 --- a/design-first-openapi-generator/src/test/resources/openapi.json.txt +++ b/design-first-openapi-generator/src/test/resources/openapi.json.txt @@ -1,37 +1,35 @@ { - "openapi": "3.0.3", - "info": { - "title": "txproc-design-first-openapi", - "version": "0.9" + "openapi" : "3.0.3", + "info" : { + "title" : "txproc-design-first-openapi", + "version" : "0.9" }, - "servers": [ - { - "url": "http://localhost:8080" - } - ], - "paths": { - "/api/txproc/pincheck": { - "post": { - "summary": "Check the pin", - "operationId": "pinCheck", - "requestBody": { - "description": "PIN Check Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" + "servers" : [ { + "url" : "http://localhost:8080" + } ], + "paths" : { + "/api/txproc/pincheck" : { + "post" : { + "summary" : "Check the pin", + "operationId" : "pinCheck", + "requestBody" : { + "description" : "PIN Check Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "PIN Check Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" + "responses" : { + "default" : { + "description" : "PIN Check Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckResponse" } } } @@ -39,28 +37,28 @@ } } }, - "/api/txproc/purchase": { - "post": { - "summary": "Authorize a Purchase", - "operationId": "purchase", - "requestBody": { - "description": "Purchase Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" + "/api/txproc/purchase" : { + "post" : { + "summary" : "Authorize a Purchase", + "operationId" : "purchase", + "requestBody" : { + "description" : "Purchase Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "Purchase Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" + "responses" : { + "default" : { + "description" : "Purchase Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthResponse" } } } @@ -69,118 +67,98 @@ } } }, - "components": { - "schemas": { - "EmvTags": { - "title": "EmvTags", - "description": "Collection of EMV tags", - "type": "object", - "properties": { - "84": { - "title": "Dedicated Filename", - "description": "The EMV AID as reported by ICC", - "type": "string" + "components" : { + "schemas" : { + "EmvTags" : { + "title" : "EmvTags", + "description" : "Collection of EMV tags", + "type" : "object", + "properties" : { + "84" : { + "title" : "Dedicated Filename", + "description" : "The EMV AID as reported by ICC", + "type" : "string" }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" + "9F1A" : { + "description" : "Terminal Country Code", + "type" : "string" } } }, - "Pan": { - "format": "string", - "title": "PAN (Primary Account Number)", - "description": "The number embossed on credit cards", - "type": "object" + "Pan" : { + "format" : "string", + "title" : "PAN (Primary Account Number)", + "description" : "The number embossed on credit cards", + "type" : "object" }, - "PinCheckRequest": { - "description": "Request for checking a PIN", - "required": [ - "pan", - "pinBlock", - "uuid" - ], - "type": "object", - "properties": { - "pan": { - "$ref": "#/components/schemas/Pan" + "PinCheckRequest" : { + "description" : "Request for checking a PIN", + "required" : [ "pan", "pinBlock", "uuid" ], + "type" : "object", + "properties" : { + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" + "pinBlock" : { + "description" : "Encrypted binary data containing a PIN\n\nFieldcode: C003", + "type" : "string" }, - "uuid": { - "format": "uuid", - "description": "Unique ID of the request", - "type": "string" + "uuid" : { + "format" : "uuid", + "description" : "Unique ID of the request", + "type" : "string" } } }, - "PinCheckResponse": { - "description": "Tells if the PIN in the request was correct", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "PinCheckResponse" : { + "description" : "Tells if the PIN in the request was correct", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "tries": { - "format": "int32", - "description": "Number of remaining tries", - "type": "integer" + "tries" : { + "format" : "int32", + "description" : "Number of remaining tries", + "type" : "integer" } } }, - "PurchaseAuthRequest": { - "description": "Request for authorizing a Purchase", - "required": [ - "pan", - "uuid" - ], - "type": "object", - "properties": { - "emvTags": { - "$ref": "#/components/schemas/EmvTags" + "PurchaseAuthRequest" : { + "description" : "Request for authorizing a Purchase", + "required" : [ "pan", "uuid" ], + "type" : "object", + "properties" : { + "emvTags" : { + "$ref" : "#/components/schemas/EmvTags" }, - "pan": { - "$ref": "#/components/schemas/Pan" + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "uuid": { - "format": "uuid", - "description": "Unique ID of the request", - "type": "string" + "uuid" : { + "format" : "uuid", + "description" : "Unique ID of the request", + "type" : "string" } } }, - "PurchaseAuthResponse": { - "description": "Response to PurchaseAuthRequest", - "type": "object", - "properties": { - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" + "PurchaseAuthResponse" : { + "description" : "Response to PurchaseAuthRequest", + "type" : "object", + "properties" : { + "approvalCode" : { + "description" : "Code referencing the successful authorization", + "type" : "string" }, - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" } } } - }, - "securitySchemes": { - "SecurityScheme": { - "type": "http", - "description": "Authentication", - "scheme": "basic" - } } } -} \ No newline at end of file +} diff --git a/design-first-openapi-generator/src/test/resources/openapi.yaml.txt b/design-first-openapi-generator/src/test/resources/openapi.yaml.txt index c126743..eb60257 100644 --- a/design-first-openapi-generator/src/test/resources/openapi.yaml.txt +++ b/design-first-openapi-generator/src/test/resources/openapi.yaml.txt @@ -123,8 +123,3 @@ components: - OK - WRONG type: string - securitySchemes: - SecurityScheme: - type: http - description: Authentication - scheme: basic diff --git a/design-first-swagger-quarkus/pom.xml b/design-first-swagger-quarkus/pom.xml index 3da586c..d2503b7 100644 --- a/design-first-swagger-quarkus/pom.xml +++ b/design-first-swagger-quarkus/pom.xml @@ -18,9 +18,9 @@ 1.18.30 - 3.4.3 - 2.2.16 - 3.0.47 + 3.5.0 + 2.2.18 + 3.0.50 2.2 @@ -28,7 +28,7 @@ 3.11.0 - 3.1.2 + 3.2.1 ${project.build.directory}/generated-sources/swagger @@ -102,6 +102,13 @@ ${json.unit.version} test + + + + io.quarkus + quarkus-smallrye-openapi-deployment + test + @@ -162,6 +169,13 @@ ${java.release} + + + org.projectlombok + lombok + ${lombok.version} + + diff --git a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt index cd019c3..b44e3d6 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt +++ b/design-first-swagger-quarkus/src/test/resources/openapi-sorted.yaml.txt @@ -123,8 +123,3 @@ components: - WRONG type: string type: object - securitySchemes: - SecurityScheme: - description: Authentication - scheme: basic - type: http diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.json.txt b/design-first-swagger-quarkus/src/test/resources/openapi.json.txt index 55fced5..16adff0 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi.json.txt +++ b/design-first-swagger-quarkus/src/test/resources/openapi.json.txt @@ -1,37 +1,35 @@ { - "openapi": "3.0.3", - "info": { - "title": "txproc-design-first-swagger", - "version": "0.9" + "openapi" : "3.0.3", + "info" : { + "title" : "txproc-design-first-swagger", + "version" : "0.9" }, - "servers": [ - { - "url": "http://localhost:8080" - } - ], - "paths": { - "/api/txproc/pincheck": { - "post": { - "summary": "Check the pin", - "operationId": "pinCheck", - "requestBody": { - "description": "PIN Check Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckRequest" + "servers" : [ { + "url" : "http://localhost:8080" + } ], + "paths" : { + "/api/txproc/pincheck" : { + "post" : { + "summary" : "Check the pin", + "operationId" : "pinCheck", + "requestBody" : { + "description" : "PIN Check Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "PIN Check Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PinCheckResponse" + "responses" : { + "default" : { + "description" : "PIN Check Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PinCheckResponse" } } } @@ -39,28 +37,28 @@ } } }, - "/api/txproc/purchase": { - "post": { - "summary": "Authorize a Purchase", - "operationId": "purchase", - "requestBody": { - "description": "Purchase Request Body", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthRequest" + "/api/txproc/purchase" : { + "post" : { + "summary" : "Authorize a Purchase", + "operationId" : "purchase", + "requestBody" : { + "description" : "Purchase Request Body", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthRequest" } } }, - "required": true + "required" : true }, - "responses": { - "default": { - "description": "Purchase Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PurchaseAuthResponse" + "responses" : { + "default" : { + "description" : "Purchase Response", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/PurchaseAuthResponse" } } } @@ -69,118 +67,98 @@ } } }, - "components": { - "schemas": { - "EmvTags": { - "title": "EmvTags", - "description": "Collection of EMV tags", - "type": "object", - "properties": { - "84": { - "title": "Dedicated Filename", - "description": "The EMV AID as reported by ICC", - "type": "string" + "components" : { + "schemas" : { + "EmvTags" : { + "title" : "EmvTags", + "description" : "Collection of EMV tags", + "type" : "object", + "properties" : { + "84" : { + "title" : "Dedicated Filename", + "description" : "The EMV AID as reported by ICC", + "type" : "string" }, - "9F1A": { - "description": "Terminal Country Code", - "type": "string" + "9F1A" : { + "description" : "Terminal Country Code", + "type" : "string" } } }, - "Pan": { - "format": "string", - "title": "PAN (Primary Account Number)", - "description": "The number embossed on credit cards", - "type": "object" + "Pan" : { + "format" : "string", + "title" : "PAN (Primary Account Number)", + "description" : "The number embossed on credit cards", + "type" : "object" }, - "PinCheckRequest": { - "description": "Request for checking a PIN", - "required": [ - "pan", - "pinBlock", - "uuid" - ], - "type": "object", - "properties": { - "pan": { - "$ref": "#/components/schemas/Pan" + "PinCheckRequest" : { + "description" : "Request for checking a PIN", + "required" : [ "pan", "pinBlock", "uuid" ], + "type" : "object", + "properties" : { + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "pinBlock": { - "description": "Encrypted binary data containing a PIN\n\nFieldcode: C003", - "type": "string" + "pinBlock" : { + "description" : "Encrypted binary data containing a PIN\n\nFieldcode: C003", + "type" : "string" }, - "uuid": { - "format": "uuid", - "description": "Unique ID of the request", - "type": "string" + "uuid" : { + "format" : "uuid", + "description" : "Unique ID of the request", + "type" : "string" } } }, - "PinCheckResponse": { - "description": "Tells if the PIN in the request was correct", - "type": "object", - "properties": { - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "PinCheckResponse" : { + "description" : "Tells if the PIN in the request was correct", + "type" : "object", + "properties" : { + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" }, - "tries": { - "format": "int32", - "description": "Number of remaining tries", - "type": "integer" + "tries" : { + "format" : "int32", + "description" : "Number of remaining tries", + "type" : "integer" } } }, - "PurchaseAuthRequest": { - "description": "Request for authorizing a Purchase", - "required": [ - "pan", - "uuid" - ], - "type": "object", - "properties": { - "emvTags": { - "$ref": "#/components/schemas/EmvTags" + "PurchaseAuthRequest" : { + "description" : "Request for authorizing a Purchase", + "required" : [ "pan", "uuid" ], + "type" : "object", + "properties" : { + "emvTags" : { + "$ref" : "#/components/schemas/EmvTags" }, - "pan": { - "$ref": "#/components/schemas/Pan" + "pan" : { + "$ref" : "#/components/schemas/Pan" }, - "uuid": { - "format": "uuid", - "description": "Unique ID of the request", - "type": "string" + "uuid" : { + "format" : "uuid", + "description" : "Unique ID of the request", + "type" : "string" } } }, - "PurchaseAuthResponse": { - "description": "Response to PurchaseAuthRequest", - "type": "object", - "properties": { - "approvalCode": { - "description": "Code referencing the successful authorization", - "type": "string" + "PurchaseAuthResponse" : { + "description" : "Response to PurchaseAuthRequest", + "type" : "object", + "properties" : { + "approvalCode" : { + "description" : "Code referencing the successful authorization", + "type" : "string" }, - "result": { - "description": "Result of the request", - "enum": [ - "OK", - "WRONG" - ], - "type": "string" + "result" : { + "description" : "Result of the request", + "enum" : [ "OK", "WRONG" ], + "type" : "string" } } } - }, - "securitySchemes": { - "SecurityScheme": { - "type": "http", - "description": "Authentication", - "scheme": "basic" - } } } } diff --git a/design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt b/design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt index 503762d..4c7e4d5 100644 --- a/design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt +++ b/design-first-swagger-quarkus/src/test/resources/openapi.yaml.txt @@ -123,8 +123,3 @@ components: - OK - WRONG type: string - securitySchemes: - SecurityScheme: - type: http - description: Authentication - scheme: basic From e317efc850bccd364a58aedd8300d87708c0b683 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Mon, 13 Nov 2023 19:32:18 +0100 Subject: [PATCH 10/12] Use Java 15 text blocks and Bean Validation annot. Also remove the string schema type for UUID, not needed anymore --- .../openapi/codefirst/txproc/PinCheckRequest.java | 11 +++++++---- .../openapi/codefirst/txproc/PurchaseAuthRequest.java | 10 ++++++---- .../apidocs/openapi/codefirst/txproc/doc/Model.java | 6 ++++-- .../swagger/codefirst/txproc/PinCheckRequest.java | 10 +++++++--- .../swagger/codefirst/txproc/PurchaseAuthRequest.java | 9 ++++++--- .../apidocs/swagger/codefirst/txproc/doc/Model.java | 6 ++++-- .../src/test/resources/openapi-sorted.yaml.txt | 2 ++ .../src/test/resources/openapi.json.txt | 2 ++ .../src/test/resources/openapi.yaml.txt | 2 ++ 9 files changed, 40 insertions(+), 18 deletions(-) diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java index bf3e8c5..eb9abca 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckRequest.java @@ -2,7 +2,8 @@ import java.util.UUID; -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import jakarta.validation.constraints.NotNull; + import org.eclipse.microprofile.openapi.annotations.media.Schema; import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.doc.Model; @@ -10,18 +11,20 @@ import lombok.Getter; import lombok.Setter; -@Schema(description = "Request for checking a PIN", - requiredProperties = {"uuid", "pan", "pinBlock"}) +@Schema(description = "Request for checking a PIN") @Getter @Setter public class PinCheckRequest { - @Schema(type = SchemaType.STRING, description = Model.UUID) + @Schema(description = Model.UUID) + @NotNull private UUID uuid; // the class Pan already carries a @Schema annotation + @NotNull private Pan pan; @Schema(description = Model.PIN_BLOCK) + @NotNull private String pinBlock; } diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java index 1c03c05..16100b1 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthRequest.java @@ -2,7 +2,8 @@ import java.util.UUID; -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; +import jakarta.validation.constraints.NotNull; + import org.eclipse.microprofile.openapi.annotations.media.Schema; import ch.schlau.pesche.apidocs.openapi.codefirst.txproc.doc.Model; @@ -11,16 +12,17 @@ import lombok.Getter; import lombok.Setter; -@Schema(description = "Request for authorizing a Purchase", - requiredProperties = {"uuid", "pan"}) +@Schema(description = "Request for authorizing a Purchase") @Getter @Setter public class PurchaseAuthRequest { - @Schema(type = SchemaType.STRING, description = Model.UUID) + @Schema(description = Model.UUID) + @NotNull private UUID uuid; // the class Pan already carries a @Schema annotation + @NotNull private Pan pan; // the class EmvTags already carries a @Schema annotation diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java index 5d2c498..601c49b 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/doc/Model.java @@ -11,7 +11,9 @@ public class Model { public static final String UUID = "Unique ID of the request"; - public static final String PIN_BLOCK = "Encrypted binary data containing a PIN" - + "\n\nFieldcode: C003"; + public static final String PIN_BLOCK = """ + Encrypted binary data containing a PIN + + Fieldcode: C003"""; } diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PinCheckRequest.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PinCheckRequest.java index 2355629..e6c35e4 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PinCheckRequest.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PinCheckRequest.java @@ -2,24 +2,28 @@ import java.util.UUID; +import jakarta.validation.constraints.NotNull; + import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.doc.Model; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.Pan; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; -@Schema(description = "Request for checking a PIN", - requiredProperties = {"uuid", "pan", "pinBlock"}) +@Schema(description = "Request for checking a PIN") @Getter @Setter public class PinCheckRequest { - @Schema(type = "string", description = Model.UUID) + @Schema(description = Model.UUID) + @NotNull private UUID uuid; // the class Pan already carries a @Schema annotation + @NotNull private Pan pan; @Schema(description = Model.PIN_BLOCK) + @NotNull private String pinBlock; } diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthRequest.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthRequest.java index ca8f53c..6705a6b 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthRequest.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthRequest.java @@ -2,6 +2,8 @@ import java.util.UUID; +import jakarta.validation.constraints.NotNull; + import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.doc.Model; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.EmvTags; import ch.schlau.pesche.apidocs.swagger.codefirst.txproc.model.Pan; @@ -9,16 +11,17 @@ import lombok.Getter; import lombok.Setter; -@Schema(description = "Request for authorizing a Purchase", - requiredProperties = {"uuid", "pan"}) +@Schema(description = "Request for authorizing a Purchase") @Getter @Setter public class PurchaseAuthRequest { - @Schema(type = "string", description = Model.UUID) + @Schema(description = Model.UUID) + @NotNull private UUID uuid; // the class Pan already carries a @Schema annotation + @NotNull private Pan pan; // the class EmvTags already carries a @Schema annotation diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/doc/Model.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/doc/Model.java index ebb40a4..b2e60f5 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/doc/Model.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/doc/Model.java @@ -11,7 +11,9 @@ public class Model { public static final String UUID = "Unique ID of the request"; - public static final String PIN_BLOCK = "Encrypted binary data containing a PIN" - + "\n\nFieldcode: C003"; + public static final String PIN_BLOCK = """ + Encrypted binary data containing a PIN + + Fieldcode: C003"""; } diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt index 65b3bc2..dba34fb 100644 --- a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt @@ -69,6 +69,7 @@ components: type: string uuid: description: Unique ID of the request + format: uuid type: string required: - pan @@ -100,6 +101,7 @@ components: type: string uuid: description: Unique ID of the request + format: uuid type: string required: - pan diff --git a/code-first-swagger/src/test/resources/openapi.json.txt b/code-first-swagger/src/test/resources/openapi.json.txt index bf912d8..3f85c9b 100644 --- a/code-first-swagger/src/test/resources/openapi.json.txt +++ b/code-first-swagger/src/test/resources/openapi.json.txt @@ -88,6 +88,7 @@ "type" : "object", "properties" : { "uuid" : { + "format" : "uuid", "description" : "Unique ID of the request", "type" : "string" }, @@ -139,6 +140,7 @@ "type" : "object", "properties" : { "uuid" : { + "format" : "uuid", "description" : "Unique ID of the request", "type" : "string" }, diff --git a/code-first-swagger/src/test/resources/openapi.yaml.txt b/code-first-swagger/src/test/resources/openapi.yaml.txt index 412e941..93d4790 100644 --- a/code-first-swagger/src/test/resources/openapi.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi.yaml.txt @@ -66,6 +66,7 @@ components: properties: uuid: description: Unique ID of the request + format: uuid type: string pan: title: PAN (Primary Account Number) @@ -111,6 +112,7 @@ components: properties: uuid: description: Unique ID of the request + format: uuid type: string pan: title: PAN (Primary Account Number) From b8aee9666e7a7e23d17f96422bda9c8cf0666d42 Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Sun, 26 Nov 2023 09:46:17 +0100 Subject: [PATCH 11/12] Move schema annotation to enum itself This works now also with Quarkus --- .../openapi/codefirst/txproc/PinCheckResponse.java | 4 ++-- .../codefirst/txproc/PurchaseAuthResponse.java | 3 ++- .../src/test/resources/openapi-sorted.yaml.txt | 12 ++++-------- .../src/test/resources/openapi.json.txt | 14 ++++---------- .../src/test/resources/openapi.yaml.txt | 12 ++++-------- .../codefirst/txproc/PurchaseAuthResponse.java | 3 ++- 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java index acd2f78..f7cf9ba 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PinCheckResponse.java @@ -10,13 +10,13 @@ @Setter public class PinCheckResponse { - // can't put @Schema annotation on the enum for Quarkus + @Schema(description = "Result of the request") public enum Code { OK, WRONG } - @Schema(description = "Result of the request") + // the enum Code already carries a @Schema annotation private Code result; @Schema(description = "Number of remaining tries") diff --git a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java index 0ae23bf..172bb10 100644 --- a/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java +++ b/code-first-openapi-quarkus/src/main/java/ch/schlau/pesche/apidocs/openapi/codefirst/txproc/PurchaseAuthResponse.java @@ -10,12 +10,13 @@ @Setter public class PurchaseAuthResponse { + @Schema(description = "Result of the request") public enum Code { OK, WRONG } - @Schema(description = "Result of the request") + // the enum Code already carries a @Schema annotation private Code result; @Schema(description = "Code referencing the successful authorization") diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt index 1f2f066..1239880 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt @@ -45,11 +45,13 @@ paths: components: schemas: Code: + description: Result of the request enum: - OK - WRONG type: string Code1: + description: Result of the request enum: - OK - WRONG @@ -95,10 +97,7 @@ components: description: Tells if the PIN in the request was correct properties: result: - allOf: - - $ref: '#/components/schemas/Code' - description: Result of the request - type: string + $ref: '#/components/schemas/Code' tries: description: Number of remaining tries format: int32 @@ -127,10 +126,7 @@ components: description: Code referencing the successful authorization type: string result: - allOf: - - $ref: '#/components/schemas/Code1' - description: Result of the request - type: string + $ref: '#/components/schemas/Code1' type: object UUID: format: uuid diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt index fa24cf1..5235fb3 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt @@ -67,10 +67,12 @@ "components" : { "schemas" : { "Code" : { + "description" : "Result of the request", "enum" : [ "OK", "WRONG" ], "type" : "string" }, "Code1" : { + "description" : "Result of the request", "enum" : [ "OK", "WRONG" ], "type" : "string" }, @@ -121,11 +123,7 @@ "type" : "object", "properties" : { "result" : { - "description" : "Result of the request", - "type" : "string", - "allOf" : [ { - "$ref" : "#/components/schemas/Code" - } ] + "$ref" : "#/components/schemas/Code" }, "tries" : { "format" : "int32", @@ -159,11 +157,7 @@ "type" : "object", "properties" : { "result" : { - "description" : "Result of the request", - "type" : "string", - "allOf" : [ { - "$ref" : "#/components/schemas/Code1" - } ] + "$ref" : "#/components/schemas/Code1" }, "approvalCode" : { "description" : "Code referencing the successful authorization", diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt index 020eddb..d7deba4 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt @@ -45,11 +45,13 @@ paths: components: schemas: Code: + description: Result of the request enum: - OK - WRONG type: string Code1: + description: Result of the request enum: - OK - WRONG @@ -96,10 +98,7 @@ components: type: object properties: result: - description: Result of the request - type: string - allOf: - - $ref: '#/components/schemas/Code' + $ref: '#/components/schemas/Code' tries: format: int32 description: Number of remaining tries @@ -125,10 +124,7 @@ components: type: object properties: result: - description: Result of the request - type: string - allOf: - - $ref: '#/components/schemas/Code1' + $ref: '#/components/schemas/Code1' approvalCode: description: Code referencing the successful authorization type: string diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthResponse.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthResponse.java index 662be71..702b190 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthResponse.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/txproc/PurchaseAuthResponse.java @@ -9,12 +9,13 @@ @Setter public class PurchaseAuthResponse { + @Schema(description = "Result of the request") public enum Code { OK, WRONG } - @Schema(description = "Result of the request") + // the enum Code already carries a @Schema annotation private Code result; @Schema(description = "Code referencing the successful authorization") From 44fbcb431a55e067323c6f008ed82472b8d291fd Mon Sep 17 00:00:00 2001 From: Peter Steiner Date: Sun, 26 Nov 2023 12:22:50 +0100 Subject: [PATCH 12/12] Add configuration for tags, operationId etc. --- .../META-INF/microprofile-config.properties | 1 + .../src/test/resources/openapi-sorted.yaml.txt | 2 ++ .../src/test/resources/openapi.json.txt | 2 ++ .../src/test/resources/openapi.yaml.txt | 2 ++ code-first-swagger/pom.xml | 1 + .../apidocs/swagger/codefirst/rest/TxProc.java | 6 ++++-- .../apidocs/swagger/codefirst/OpenapiDocumentIT.java | 3 +-- .../src/test/resources/openapi-sorted.yaml.txt | 8 ++++++-- .../src/test/resources/openapi.json.txt | 6 ++++-- .../src/test/resources/openapi.yaml.txt | 12 ++++++++---- 10 files changed, 31 insertions(+), 12 deletions(-) diff --git a/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties b/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties index 7b4e1c9..cb0d7d6 100644 --- a/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties +++ b/code-first-openapi-quarkus/src/main/resources/META-INF/microprofile-config.properties @@ -1,4 +1,5 @@ # Smallrye-specific options +mp.openapi.extensions.smallrye.operationIdStrategy=METHOD # keep /openapi instead /q/openapi for the time being # see https://quarkus.io/blog/path-resolution-in-quarkus/ diff --git a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt index 1239880..29d8a32 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi-sorted.yaml.txt @@ -6,6 +6,7 @@ info: paths: /api/txproc/pincheck: post: + operationId: pinCheck requestBody: content: application/json: @@ -25,6 +26,7 @@ paths: - Tx Proc /api/txproc/purchase: post: + operationId: purchase requestBody: content: application/json: diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt index 5235fb3..b809030 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.json.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.json.txt @@ -9,6 +9,7 @@ "post" : { "tags" : [ "Tx Proc" ], "summary" : "Check the pin", + "operationId" : "pinCheck", "requestBody" : { "description" : "PIN Check Request Body", "content" : { @@ -38,6 +39,7 @@ "post" : { "tags" : [ "Tx Proc" ], "summary" : "Authorize a Purchase", + "operationId" : "purchase", "requestBody" : { "description" : "Purchase Request Body", "content" : { diff --git a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt index d7deba4..9a4bd08 100644 --- a/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt +++ b/code-first-openapi-quarkus/src/test/resources/openapi.yaml.txt @@ -9,6 +9,7 @@ paths: tags: - Tx Proc summary: Check the pin + operationId: pinCheck requestBody: description: PIN Check Request Body content: @@ -28,6 +29,7 @@ paths: tags: - Tx Proc summary: Authorize a Purchase + operationId: purchase requestBody: description: Purchase Request Body content: diff --git a/code-first-swagger/pom.xml b/code-first-swagger/pom.xml index 9fd6ff1..234bb61 100755 --- a/code-first-swagger/pom.xml +++ b/code-first-swagger/pom.xml @@ -120,6 +120,7 @@ ch.schlau.pesche.apidocs.swagger.codefirst true + true diff --git a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java index 99df2e1..01fb72c 100644 --- a/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java +++ b/code-first-swagger/src/main/java/ch/schlau/pesche/apidocs/swagger/codefirst/rest/TxProc.java @@ -27,7 +27,8 @@ public class TxProc { @Path("/pincheck") @POST - @Operation(summary = "Check the pin") + @Operation(summary = "Check the pin", + tags = {"Tx Proc"}) @ApiResponse(description = "PIN Check Response", content = @Content(schema = @Schema(implementation = PinCheckResponse.class))) public PinCheckResponse pinCheck( @@ -48,7 +49,8 @@ public PinCheckResponse pinCheck( @Path("/purchase") @POST - @Operation(summary = "Authorize a Purchase") + @Operation(summary = "Authorize a Purchase", + tags = {"Tx Proc"}) @ApiResponse(description = "Purchase Response", content = @Content(schema = @Schema(implementation = PurchaseAuthResponse.class))) public PurchaseAuthResponse purchase( diff --git a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java index d9a7569..499ea50 100644 --- a/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java +++ b/code-first-swagger/src/test/java/ch/schlau/pesche/apidocs/swagger/codefirst/OpenapiDocumentIT.java @@ -55,8 +55,7 @@ void openapi_yaml() throws IOException { String yamlSorted = sortYaml(document); assertAll("openapi yaml" - // the unsorted document generated by Swagger has no deterministic order - // , () -> assertThat("unsorted", document, is(expected)) + , () -> assertThat("unsorted", document, is(expected)) , () -> assertThat("sorted", yamlSorted, is(expectedSorted)) ); } diff --git a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt index dba34fb..e1d91c2 100644 --- a/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi-sorted.yaml.txt @@ -4,7 +4,7 @@ info: title: txproc-code-first-swagger version: 0.9 paths: - /txproc/pincheck: + /api/txproc/pincheck: post: operationId: pinCheck requestBody: @@ -22,7 +22,9 @@ paths: $ref: '#/components/schemas/PinCheckResponse' description: PIN Check Response summary: Check the pin - /txproc/purchase: + tags: + - Tx Proc + /api/txproc/purchase: post: operationId: purchase requestBody: @@ -40,6 +42,8 @@ paths: $ref: '#/components/schemas/PurchaseAuthResponse' description: Purchase Response summary: Authorize a Purchase + tags: + - Tx Proc components: schemas: EmvTags: diff --git a/code-first-swagger/src/test/resources/openapi.json.txt b/code-first-swagger/src/test/resources/openapi.json.txt index 3f85c9b..d290446 100644 --- a/code-first-swagger/src/test/resources/openapi.json.txt +++ b/code-first-swagger/src/test/resources/openapi.json.txt @@ -5,8 +5,9 @@ "version" : "0.9" }, "paths" : { - "/txproc/pincheck" : { + "/api/txproc/pincheck" : { "post" : { + "tags" : [ "Tx Proc" ], "summary" : "Check the pin", "operationId" : "pinCheck", "requestBody" : { @@ -34,8 +35,9 @@ } } }, - "/txproc/purchase" : { + "/api/txproc/purchase" : { "post" : { + "tags" : [ "Tx Proc" ], "summary" : "Authorize a Purchase", "operationId" : "purchase", "requestBody" : { diff --git a/code-first-swagger/src/test/resources/openapi.yaml.txt b/code-first-swagger/src/test/resources/openapi.yaml.txt index 93d4790..f1e2b25 100644 --- a/code-first-swagger/src/test/resources/openapi.yaml.txt +++ b/code-first-swagger/src/test/resources/openapi.yaml.txt @@ -4,8 +4,10 @@ info: title: txproc-code-first-swagger version: "0.9" paths: - /txproc/pincheck: + /api/txproc/pincheck: post: + tags: + - Tx Proc summary: Check the pin operationId: pinCheck requestBody: @@ -22,8 +24,10 @@ paths: application/json: schema: $ref: '#/components/schemas/PinCheckResponse' - /txproc/purchase: + /api/txproc/purchase: post: + tags: + - Tx Proc summary: Authorize a Purchase operationId: purchase requestBody: @@ -65,8 +69,8 @@ components: type: object properties: uuid: - description: Unique ID of the request format: uuid + description: Unique ID of the request type: string pan: title: PAN (Primary Account Number) @@ -111,8 +115,8 @@ components: type: object properties: uuid: - description: Unique ID of the request format: uuid + description: Unique ID of the request type: string pan: title: PAN (Primary Account Number)