Skip to content

Commit

Permalink
feat: updated swagger doc response sample and env file
Browse files Browse the repository at this point in the history
  • Loading branch information
thackerronak committed Jul 19, 2023
1 parent 3257ffd commit cba1d5f
Show file tree
Hide file tree
Showing 4 changed files with 609 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev-assets/env-files/env.docker.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AUTHORITY_WALLET_NAME=Catena-X
KEYCLOAK_REALM=miw_test
VC_SCHEMA_LINK="https://www.w3.org/2018/credentials/v1, https://catenax-ng.github.io/product-core-schemas/businessPartnerData.json"
VC_EXPIRY_DATE=01-01-2025
SUPPORTED_FRAMEWORK_VC_TYPES="cx-behavior-twin=Behavior Twin,cx-pcf=PCF,cx-quality=Quality,cx-resiliency=Resiliency,cx-sustainability=Sustainability,cx-traceability=ID_3.0_Trace"
SUPPORTED_FRAMEWORK_VC_TYPES="PcfCredential, SustainabilityCredential, QualityCredential, TraceabilityCredential, BehaviorTwinCredential, ResiliencyCredential"
MIW_HOST_NAME=miw

######### DON'T MODIFY ANYTHING BELOW THIS LINE !!! #########
Expand Down
2 changes: 1 addition & 1 deletion dev-assets/env-files/env.local.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AUTHORITY_WALLET_NAME=Catena-X
KEYCLOAK_REALM=miw_test
VC_SCHEMA_LINK="https://www.w3.org/2018/credentials/v1, https://catenax-ng.github.io/product-core-schemas/businessPartnerData.json"
VC_EXPIRY_DATE=01-01-2025
SUPPORTED_FRAMEWORK_VC_TYPES="cx-behavior-twin=Behavior Twin,cx-pcf=PCF,cx-quality=Quality,cx-resiliency=Resiliency,cx-sustainability=Sustainability,cx-traceability=ID_3.0_Trace"
SUPPORTED_FRAMEWORK_VC_TYPES="PcfCredential, SustainabilityCredential, QualityCredential, TraceabilityCredential, BehaviorTwinCredential, ResiliencyCredential"
MIW_HOST_NAME=miw

######### DON'T MODIFY ANYTHING BELOW THIS LINE !!! #########
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.eclipse.tractusx.managedidentitywallets.constant.RestURI;
Expand Down Expand Up @@ -50,9 +53,62 @@ public class DidDocumentController {
* @param identifier the identifier
* @return the did document
*/
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
})})
@ApiResponse(responseCode = "404", description = "Wallet not found with provided bpn", content = {@Content(examples = {
@ExampleObject(name = "Wallet not found with provided bpn", value = """
{
"type": "about:blank",
"title": "Wallet not found for identifier BPNL00000000000",
"status": 404,
"detail": "Wallet not found for identifier BPNL00000000000",
"instance": "/BPNL00000000000/did.json",
"properties": {
"timestamp": 1689767698010
}
}
""")
})})
@ApiResponse(responseCode = "200", description = "DID document", content = {
@Content(examples = {
@ExampleObject(name = " DID document", value = """
{
"id": "did:web:localhost:BPNL000000000000",
"verificationMethod": [
{
"controller": "did:web:localhost:BPNL000000000000",
"id": "did:web:localhost:BPNL000000000000#",
"publicKeyJwk": {
"crv": "Ed25519",
"kty": "OKP",
"x": "wAOQvr92L1m7RwrpeOrgWByVYvWmhRr4fJbiMwHEIdY"
},
"type": "JsonWebKey2020"
}
],
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
]
}
""")
})
})
@Operation(description = "Resolve the DID document for a given DID or BPN", summary = "Resolve DID Document")
@GetMapping(path = RestURI.DID_DOCUMENTS, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DidDocument> getDidDocument(@Parameter(description = "Did or BPN") @PathVariable(name = "identifier") String identifier) {
public ResponseEntity<DidDocument> getDidDocument(@Parameter(description = "Did or BPN",examples = {@ExampleObject(name = "bpn", value = "BPNL000000000000", description = "bpn"), @ExampleObject(description = "did", name = "did", value = "did:web:localhost:BPNL000000000000")}) @PathVariable(name = "identifier") String identifier) {
return ResponseEntity.status(HttpStatus.OK).body(service.getDidDocument(identifier));
}

Expand All @@ -62,9 +118,62 @@ public ResponseEntity<DidDocument> getDidDocument(@Parameter(description = "Did
* @param bpn the bpn
* @return the did resolve
*/
@ApiResponse(responseCode = "500", description = "Any other internal server error", content = {@Content(examples = {
@ExampleObject(name = "Internal server error", value = """
{
"type": "about:blank",
"title": "Error Title",
"status": 500,
"detail": "Error Details",
"instance": "API endpoint",
"properties": {
"timestamp": 1689762476720
}
}
""")
})})
@ApiResponse(responseCode = "404", description = "Wallet not found with provided bpn", content = {@Content(examples = {
@ExampleObject(name = "Wallet not found with provided bpn", value = """
{
"type": "about:blank",
"title": "Wallet not found for identifier BPNL00000000000",
"status": 404,
"detail": "Wallet not found for identifier BPNL00000000000",
"instance": "/BPNL00000000000/did.json",
"properties": {
"timestamp": 1689767698010
}
}
""")
})})
@ApiResponse(responseCode = "200", description = "DID document", content = {
@Content(examples = {
@ExampleObject(name = " DID document", value = """
{
"id": "did:web:localhost:BPNL000000000000",
"verificationMethod": [
{
"controller": "did:web:localhost:BPNL000000000000",
"id": "did:web:localhost:BPNL000000000000#",
"publicKeyJwk": {
"crv": "Ed25519",
"kty": "OKP",
"x": "wAOQvr92L1m7RwrpeOrgWByVYvWmhRr4fJbiMwHEIdY"
},
"type": "JsonWebKey2020"
}
],
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3c.github.io/vc-jws-2020/contexts/v1"
]
}
""")
})
})
@Operation(description = "Resolve the DID document for a given BPN", summary = "Resolve DID Document")
@GetMapping(path = RestURI.DID_RESOLVE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DidDocument> getDidResolve(@Parameter(description = "Did or BPN") @PathVariable(name = "bpn") String bpn) {
public ResponseEntity<DidDocument> getDidResolve(@Parameter(description = "BPN",examples = {@ExampleObject(name = "bpn", value = "BPNL000000000000", description = "bpn")}) @PathVariable(name = "bpn") String bpn) {
return ResponseEntity.status(HttpStatus.OK).body(service.getDidDocument(bpn));
}
}
Loading

0 comments on commit cba1d5f

Please sign in to comment.