Skip to content

Commit f98b0cd

Browse files
Merge pull request #164 from pagopa/fix-openapi-generation-for-v2
fix: OpenApi generation for v2 API
2 parents 5fa2dd4 + 90e1b15 commit f98b0cd

File tree

6 files changed

+135
-119
lines changed

6 files changed

+135
-119
lines changed

openapi/openapi-node-v1.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,28 @@
550550
}
551551
}
552552
},
553+
"ProblemJson": {
554+
"type": "object",
555+
"properties": {
556+
"title": {
557+
"type": "string",
558+
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
559+
},
560+
"status": {
561+
"maximum": 600,
562+
"minimum": 100,
563+
"type": "integer",
564+
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
565+
"format": "int32",
566+
"example": 200
567+
},
568+
"detail": {
569+
"type": "string",
570+
"description": "A human readable explanation specific to this occurrence of the problem.",
571+
"example": "There was an error processing the request"
572+
}
573+
}
574+
},
553575
"BundleOption": {
554576
"type": "object",
555577
"properties": {
@@ -614,28 +636,6 @@
614636
}
615637
}
616638
},
617-
"ProblemJson": {
618-
"type": "object",
619-
"properties": {
620-
"title": {
621-
"type": "string",
622-
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
623-
},
624-
"status": {
625-
"maximum": 600,
626-
"minimum": 100,
627-
"type": "integer",
628-
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
629-
"format": "int32",
630-
"example": 200
631-
},
632-
"detail": {
633-
"type": "string",
634-
"description": "A human readable explanation specific to this occurrence of the problem.",
635-
"example": "There was an error processing the request"
636-
}
637-
}
638-
},
639639
"PaymentOption": {
640640
"required": [
641641
"paymentAmount",
@@ -715,4 +715,4 @@
715715
}
716716
}
717717
}
718-
}
718+
}

openapi/openapi-node-v2.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
],
3939
"paths": {
40-
"/fees/multi": {
40+
"/fees": {
4141
"post": {
4242
"tags": [
4343
"Calculator"
@@ -321,7 +321,7 @@
321321
}
322322
]
323323
},
324-
"/psps/{idPsp}/fees/multi": {
324+
"/psps/{idPsp}/fees": {
325325
"post": {
326326
"tags": [
327327
"Calculator"
@@ -569,6 +569,28 @@
569569
}
570570
}
571571
},
572+
"ProblemJson": {
573+
"type": "object",
574+
"properties": {
575+
"title": {
576+
"type": "string",
577+
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
578+
},
579+
"status": {
580+
"maximum": 600,
581+
"minimum": 100,
582+
"type": "integer",
583+
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
584+
"format": "int32",
585+
"example": 200
586+
},
587+
"detail": {
588+
"type": "string",
589+
"description": "A human readable explanation specific to this occurrence of the problem.",
590+
"example": "There was an error processing the request"
591+
}
592+
}
593+
},
572594
"BundleOption": {
573595
"type": "object",
574596
"properties": {
@@ -661,28 +683,6 @@
661683
}
662684
}
663685
},
664-
"ProblemJson": {
665-
"type": "object",
666-
"properties": {
667-
"title": {
668-
"type": "string",
669-
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
670-
},
671-
"status": {
672-
"maximum": 600,
673-
"minimum": 100,
674-
"type": "integer",
675-
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
676-
"format": "int32",
677-
"example": 200
678-
},
679-
"detail": {
680-
"type": "string",
681-
"description": "A human readable explanation specific to this occurrence of the problem.",
682-
"example": "There was an error processing the request"
683-
}
684-
}
685-
},
686686
"PaymentOptionMulti": {
687687
"required": [
688688
"paymentNotice"
@@ -753,4 +753,4 @@
753753
}
754754
}
755755
}
756-
}
756+
}

openapi/openapi-v1-dev-uat.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,28 @@
10401040
}
10411041
}
10421042
},
1043+
"ProblemJson": {
1044+
"type": "object",
1045+
"properties": {
1046+
"title": {
1047+
"type": "string",
1048+
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
1049+
},
1050+
"status": {
1051+
"maximum": 600,
1052+
"minimum": 100,
1053+
"type": "integer",
1054+
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
1055+
"format": "int32",
1056+
"example": 200
1057+
},
1058+
"detail": {
1059+
"type": "string",
1060+
"description": "A human readable explanation specific to this occurrence of the problem.",
1061+
"example": "There was an error processing the request"
1062+
}
1063+
}
1064+
},
10431065
"BundleOption": {
10441066
"type": "object",
10451067
"properties": {
@@ -1104,28 +1126,6 @@
11041126
}
11051127
}
11061128
},
1107-
"ProblemJson": {
1108-
"type": "object",
1109-
"properties": {
1110-
"title": {
1111-
"type": "string",
1112-
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
1113-
},
1114-
"status": {
1115-
"maximum": 600,
1116-
"minimum": 100,
1117-
"type": "integer",
1118-
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
1119-
"format": "int32",
1120-
"example": 200
1121-
},
1122-
"detail": {
1123-
"type": "string",
1124-
"description": "A human readable explanation specific to this occurrence of the problem.",
1125-
"example": "There was an error processing the request"
1126-
}
1127-
}
1128-
},
11291129
"PaymentOption": {
11301130
"required": [
11311131
"paymentAmount",
@@ -1379,4 +1379,4 @@
13791379
}
13801380
}
13811381
}
1382-
}
1382+
}

openapi/openapi-v1.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,28 @@
550550
}
551551
}
552552
},
553+
"ProblemJson": {
554+
"type": "object",
555+
"properties": {
556+
"title": {
557+
"type": "string",
558+
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
559+
},
560+
"status": {
561+
"maximum": 600,
562+
"minimum": 100,
563+
"type": "integer",
564+
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
565+
"format": "int32",
566+
"example": 200
567+
},
568+
"detail": {
569+
"type": "string",
570+
"description": "A human readable explanation specific to this occurrence of the problem.",
571+
"example": "There was an error processing the request"
572+
}
573+
}
574+
},
553575
"BundleOption": {
554576
"type": "object",
555577
"properties": {
@@ -614,28 +636,6 @@
614636
}
615637
}
616638
},
617-
"ProblemJson": {
618-
"type": "object",
619-
"properties": {
620-
"title": {
621-
"type": "string",
622-
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
623-
},
624-
"status": {
625-
"maximum": 600,
626-
"minimum": 100,
627-
"type": "integer",
628-
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
629-
"format": "int32",
630-
"example": 200
631-
},
632-
"detail": {
633-
"type": "string",
634-
"description": "A human readable explanation specific to this occurrence of the problem.",
635-
"example": "There was an error processing the request"
636-
}
637-
}
638-
},
639639
"PaymentOption": {
640640
"required": [
641641
"paymentAmount",
@@ -715,4 +715,4 @@
715715
}
716716
}
717717
}
718-
}
718+
}

openapi/openapi-v2.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
],
3939
"paths": {
40-
"/fees/multi": {
40+
"/fees": {
4141
"post": {
4242
"tags": [
4343
"Calculator"
@@ -321,7 +321,7 @@
321321
}
322322
]
323323
},
324-
"/psps/{idPsp}/fees/multi": {
324+
"/psps/{idPsp}/fees": {
325325
"post": {
326326
"tags": [
327327
"Calculator"
@@ -569,6 +569,28 @@
569569
}
570570
}
571571
},
572+
"ProblemJson": {
573+
"type": "object",
574+
"properties": {
575+
"title": {
576+
"type": "string",
577+
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
578+
},
579+
"status": {
580+
"maximum": 600,
581+
"minimum": 100,
582+
"type": "integer",
583+
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
584+
"format": "int32",
585+
"example": 200
586+
},
587+
"detail": {
588+
"type": "string",
589+
"description": "A human readable explanation specific to this occurrence of the problem.",
590+
"example": "There was an error processing the request"
591+
}
592+
}
593+
},
572594
"BundleOption": {
573595
"type": "object",
574596
"properties": {
@@ -661,28 +683,6 @@
661683
}
662684
}
663685
},
664-
"ProblemJson": {
665-
"type": "object",
666-
"properties": {
667-
"title": {
668-
"type": "string",
669-
"description": "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
670-
},
671-
"status": {
672-
"maximum": 600,
673-
"minimum": 100,
674-
"type": "integer",
675-
"description": "The HTTP status code generated by the origin server for this occurrence of the problem.",
676-
"format": "int32",
677-
"example": 200
678-
},
679-
"detail": {
680-
"type": "string",
681-
"description": "A human readable explanation specific to this occurrence of the problem.",
682-
"example": "There was an error processing the request"
683-
}
684-
}
685-
},
686686
"PaymentOptionMulti": {
687687
"required": [
688688
"paymentNotice"
@@ -753,4 +753,4 @@
753753
}
754754
}
755755
}
756-
}
756+
}

src/main/java/it/gov/pagopa/afm/calculator/config/SwaggerConfig.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,26 @@ public Map<String, GroupedOpenApi> configureGroupOpenApi(
137137
} else {
138138
openApi.setServers(buildOpenapiServers(List.of(BASE_PATH), BASE_PATH));
139139
}
140+
if (id.equals("v2") || id.equals("node_v2")) {
141+
openApi.setPaths(removeMultiFromPath(openApi.getPaths()));
142+
}
140143
}));
141144
return groupOpenApi;
142145
}
143146

147+
private Paths removeMultiFromPath(Paths paths) {
148+
Paths updated = new Paths();
149+
paths.forEach(
150+
(k, v) -> {
151+
if (k.contains("/multi")) {
152+
updated.addPathItem(k.replace("/multi", ""), v);
153+
} else {
154+
updated.addPathItem(k, v);
155+
}
156+
});
157+
return updated;
158+
}
159+
144160
private List<Server> buildOpenapiServers(List<String> basePathList, String defaultBasePath) {
145161
return List.of(
146162
new Server().url("http://localhost:8080"),

0 commit comments

Comments
 (0)