From 08951e85d4e144d1eb76d49e3de31c6022475361 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 24 Apr 2024 12:05:18 +0100 Subject: [PATCH 1/4] Add base API url to contract api result Signed-off-by: Enrique Lacal --- internal/contracts/manager.go | 1 + internal/contracts/manager_test.go | 2 ++ pkg/core/contracts.go | 1 + 3 files changed, 4 insertions(+) diff --git a/internal/contracts/manager.go b/internal/contracts/manager.go index 359e66795..46778e94c 100644 --- a/internal/contracts/manager.go +++ b/internal/contracts/manager.go @@ -505,6 +505,7 @@ func (cm *contractManager) addContractURLs(httpServerURL string, api *core.Contr baseURL := fmt.Sprintf("%s/apis/%s", httpServerURL, api.Name) api.URLs.OpenAPI = baseURL + "/api/swagger.json" api.URLs.UI = baseURL + "/api" + api.URLs.API = baseURL } } diff --git a/internal/contracts/manager_test.go b/internal/contracts/manager_test.go index 9587a65d5..65fc53fba 100644 --- a/internal/contracts/manager_test.go +++ b/internal/contracts/manager_test.go @@ -3214,6 +3214,7 @@ func TestGetContractAPI(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana/api/swagger.json", result.URLs.OpenAPI) assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana/api", result.URLs.UI) + assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana", result.URLs.API) } func TestGetContractAPIs(t *testing.T) { @@ -3235,6 +3236,7 @@ func TestGetContractAPIs(t *testing.T) { assert.Equal(t, 1, len(results)) assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana/api/swagger.json", results[0].URLs.OpenAPI) assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana/api", results[0].URLs.UI) + assert.Equal(t, "http://localhost/api/v1/namespaces/ns1/apis/banana", results[0].URLs.API) } func TestGetContractAPIInterface(t *testing.T) { diff --git a/pkg/core/contracts.go b/pkg/core/contracts.go index b9c1adb2b..f8678e22b 100644 --- a/pkg/core/contracts.go +++ b/pkg/core/contracts.go @@ -57,6 +57,7 @@ type ContractDeployRequest struct { type ContractURLs struct { OpenAPI string `ffstruct:"ContractURLs" json:"openapi"` UI string `ffstruct:"ContractURLs" json:"ui"` + API string `ffstruct:"ContractURLs" json:"api"` } type ContractAPI struct { From 8f7e51d4bccaf29c0d0f82637455efc293109d83 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 24 Apr 2024 12:12:00 +0100 Subject: [PATCH 2/4] Add field description for Contract URL API Signed-off-by: Enrique Lacal --- docs/reference/types/contractapi.md | 4 ++- docs/swagger/swagger.yaml | 36 +++++++++++++++++++++ internal/coremsgs/en_struct_descriptions.go | 1 + internal/reference/reference.go | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/docs/reference/types/contractapi.md b/docs/reference/types/contractapi.md index 403fd7953..30d426d54 100644 --- a/docs/reference/types/contractapi.md +++ b/docs/reference/types/contractapi.md @@ -36,7 +36,8 @@ nav_order: 4 "message": "b09d9f77-7b16-4760-a8d7-0e3c319b2a16", "urls": { "openapi": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api/swagger.json", - "ui": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api" + "ui": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api", + "api": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api" }, "published": false } @@ -71,5 +72,6 @@ nav_order: 4 |------------|-------------|------| | `openapi` | The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format | `string` | | `ui` | The URL to use in a web browser to access the SwaggerUI explorer/exerciser for the API | `string` | +| `api` | The URL to use to invoke the API | `string` | diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 0564c667c..48c430e61 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -129,6 +129,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -253,6 +256,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -315,6 +321,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -427,6 +436,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -551,6 +563,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -613,6 +628,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -11944,6 +11962,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -12075,6 +12096,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -12137,6 +12161,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -12263,6 +12290,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -12394,6 +12424,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format @@ -12456,6 +12489,9 @@ paths: urls: description: The URLs to use to access the API properties: + api: + description: The URL to use to invoke the API + type: string openapi: description: The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index 4356b1455..fee36b245 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -236,6 +236,7 @@ var ( // ContractURLs field descriptions ContractURLsOpenAPI = ffm("ContractURLs.openapi", "The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format") ContractURLsUI = ffm("ContractURLs.ui", "The URL to use in a web browser to access the SwaggerUI explorer/exerciser for the API") + ContractURLsAPI = ffm("ContractURLs.api", "The URL to use to invoke the API") // FFIReference field descriptions FFIReferenceID = ffm("FFIReference.id", "The UUID of the FireFly interface") diff --git a/internal/reference/reference.go b/internal/reference/reference.go index 19432f5c2..acfad70c9 100644 --- a/internal/reference/reference.go +++ b/internal/reference/reference.go @@ -102,6 +102,7 @@ func GenerateObjectsReferenceMarkdown(ctx context.Context) (map[string][]byte, e URLs: core.ContractURLs{ OpenAPI: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api/swagger.json", UI: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api", + API: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api", }, }, From 420423ac721f0f90c56ad222af006daeafabdd77 Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 24 Apr 2024 12:15:21 +0100 Subject: [PATCH 3/4] Reorder Signed-off-by: Enrique Lacal --- docs/reference/types/contractapi.md | 6 +++--- internal/coremsgs/en_struct_descriptions.go | 2 +- internal/reference/reference.go | 2 +- pkg/core/contracts.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/reference/types/contractapi.md b/docs/reference/types/contractapi.md index 30d426d54..4672686f4 100644 --- a/docs/reference/types/contractapi.md +++ b/docs/reference/types/contractapi.md @@ -35,9 +35,9 @@ nav_order: 4 "name": "my_contract_api", "message": "b09d9f77-7b16-4760-a8d7-0e3c319b2a16", "urls": { + "api": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api", "openapi": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api/swagger.json", - "ui": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api", - "api": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api" + "ui": "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api" }, "published": false } @@ -70,8 +70,8 @@ nav_order: 4 | Field Name | Description | Type | |------------|-------------|------| +| `api` | The URL to use to invoke the API | `string` | | `openapi` | The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format | `string` | | `ui` | The URL to use in a web browser to access the SwaggerUI explorer/exerciser for the API | `string` | -| `api` | The URL to use to invoke the API | `string` | diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index fee36b245..96f7ca17c 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -234,9 +234,9 @@ var ( ContractAPIPublished = ffm("ContractAPI.published", "Indicates if the API is published to other members of the multiparty network") // ContractURLs field descriptions + ContractURLsAPI = ffm("ContractURLs.api", "The URL to use to invoke the API") ContractURLsOpenAPI = ffm("ContractURLs.openapi", "The URL to download the OpenAPI v3 (Swagger) description for the API generated in JSON or YAML format") ContractURLsUI = ffm("ContractURLs.ui", "The URL to use in a web browser to access the SwaggerUI explorer/exerciser for the API") - ContractURLsAPI = ffm("ContractURLs.api", "The URL to use to invoke the API") // FFIReference field descriptions FFIReferenceID = ffm("FFIReference.id", "The UUID of the FireFly interface") diff --git a/internal/reference/reference.go b/internal/reference/reference.go index acfad70c9..272f63272 100644 --- a/internal/reference/reference.go +++ b/internal/reference/reference.go @@ -100,9 +100,9 @@ func GenerateObjectsReferenceMarkdown(ctx context.Context) (map[string][]byte, e }`), Message: fftypes.MustParseUUID("b09d9f77-7b16-4760-a8d7-0e3c319b2a16"), URLs: core.ContractURLs{ + API: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api", OpenAPI: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api/swagger.json", UI: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api/api", - API: "http://127.0.0.1:5000/api/v1/namespaces/default/apis/my_contract_api", }, }, diff --git a/pkg/core/contracts.go b/pkg/core/contracts.go index f8678e22b..bfd02f6e0 100644 --- a/pkg/core/contracts.go +++ b/pkg/core/contracts.go @@ -55,9 +55,9 @@ type ContractDeployRequest struct { } type ContractURLs struct { + API string `ffstruct:"ContractURLs" json:"api"` OpenAPI string `ffstruct:"ContractURLs" json:"openapi"` UI string `ffstruct:"ContractURLs" json:"ui"` - API string `ffstruct:"ContractURLs" json:"api"` } type ContractAPI struct { From 365337b52b8ca1fcda862bdcebbc0663d0d971fa Mon Sep 17 00:00:00 2001 From: Enrique Lacal Date: Wed, 24 Apr 2024 13:44:13 +0100 Subject: [PATCH 4/4] fix copyright Signed-off-by: Enrique Lacal --- internal/reference/reference.go | 2 +- pkg/core/contracts.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/reference/reference.go b/internal/reference/reference.go index 272f63272..2882180af 100644 --- a/internal/reference/reference.go +++ b/internal/reference/reference.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Kaleido, Inc. +// Copyright © 2024 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 // diff --git a/pkg/core/contracts.go b/pkg/core/contracts.go index bfd02f6e0..92a1efc3e 100644 --- a/pkg/core/contracts.go +++ b/pkg/core/contracts.go @@ -1,4 +1,4 @@ -// Copyright © 2023 Kaleido, Inc. +// Copyright © 2024 Kaleido, Inc. // // SPDX-License-Identifier: Apache-2.0 //