Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/apiserver/route_get_identity_by_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import (
"github.com/hyperledger/firefly/pkg/core"
)

// @Summary Get identity by ID
// @ID getIdentityByID
// @Tags identities
// @Produce json
// @Param iid path string true "Identity ID"
// @Success 200 {object} core.Identity
// @Router /identities/{iid} [get]
var getIdentityByID = &ffapi.Route{
Name: "getIdentityByID",
Path: "identities/{iid}",
Expand Down
9 changes: 9 additions & 0 deletions internal/apiserver/route_patch_update_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ import (
"github.com/hyperledger/firefly/pkg/core"
)

// @Summary Update an identity
// @ID patchUpdateIdentity
// @Tags identities
// @Accept json
// @Produce json
// @Param iid path string true "Identity ID" <-- THE CRITICAL FIX
// @Param body body core.IdentityUpdateDTO true "Identity update details"
// @Success 202 {object} core.Identity
// @Router /identities/{iid} [patch]
var patchUpdateIdentity = &ffapi.Route{
Name: "patchUpdateIdentity",
Path: "identities/{iid}",
Expand Down
177 changes: 90 additions & 87 deletions internal/apiserver/route_post_data.go
Original file line number Diff line number Diff line change
@@ -1,87 +1,90 @@
// Copyright © 2022 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

var postData = &ffapi.Route{
Name: "postData",
Path: "data",
Method: http.MethodPost,
PathParams: nil,
QueryParams: nil,
FormParams: []*ffapi.FormParam{
{Name: "autometa", Description: coremsgs.APIParamsAutometa},
{Name: "metadata", Description: coremsgs.APIParamsMetadata},
{Name: "validator", Description: coremsgs.APIParamsValidator},
{Name: "datatype.name", Description: coremsgs.APIParamsDatatypeName},
{Name: "datatype.version", Description: coremsgs.APIParamsDatatypeVersion},
},
Description: coremsgs.APIEndpointsPostData,
JSONInputValue: func() interface{} { return &core.DataRefOrValue{} },
JSONOutputValue: func() interface{} { return &core.Data{} },
JSONOutputCodes: []int{http.StatusCreated},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Data() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
output, err = cr.or.Data().UploadJSON(cr.ctx, r.Input.(*core.DataRefOrValue))
return output, err
},
CoreFormUploadHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
if !cr.or.Data().BlobsEnabled() {
return nil, i18n.NewError(r.Req.Context(), coremsgs.MsgActionNotSupported)
}

data := &core.DataRefOrValue{}
validator := r.FP["validator"]
if len(validator) > 0 {
data.Validator = core.ValidatorType(validator)
}
if r.FP["datatype.name"] != "" {
data.Datatype = &core.DatatypeRef{
Name: r.FP["datatype.name"],
Version: r.FP["datatype.version"],
}
}
metadata := r.FP["metadata"]
if len(metadata) > 0 {
// The metadata might be JSON, or just a simple string. Try to unmarshal and see
var marshalCheck interface{}
if err := json.Unmarshal([]byte(metadata), &marshalCheck); err != nil {
metadata = fmt.Sprintf(`"%s"`, metadata)
}
data.Value = fftypes.JSONAnyPtr(metadata)
}
output, err = cr.or.Data().UploadBlob(cr.ctx, data, r.Part, strings.EqualFold(r.FP["autometa"], "true"))
return output, err
},
},
}
// Copyright © 2022 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package apiserver

import (
"encoding/json"
"fmt"
"net/http"
"strings"

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly-common/pkg/i18n"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

var postData = &ffapi.Route{
Name: "postData",
Path: "data",
Method: http.MethodPost,
PathParams: nil,
QueryParams: nil,
FormParams: []*ffapi.FormParam{
{Name: "autometa", Description: coremsgs.APIParamsAutometa},
{Name: "metadata", Description: coremsgs.APIParamsMetadata},
{Name: "validator", Description: coremsgs.APIParamsValidator},
{Name: "datatype.name", Description: coremsgs.APIParamsDatatypeName},
{Name: "datatype.version", Description: coremsgs.APIParamsDatatypeVersion},
},
Description: coremsgs.APIEndpointsPostData,
JSONInputValue: func() interface{} { return &core.DataRefOrValue{} },
JSONOutputValue: func() interface{} { return &core.Data{} },
JSONOutputCodes: []int{http.StatusCreated},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Data() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
output, err = cr.or.Data().UploadJSON(cr.ctx, r.Input.(*core.DataRefOrValue))
return output, err
},
CoreFormUploadHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
if !cr.or.Data().BlobsEnabled() {
return nil, i18n.NewError(r.Req.Context(), coremsgs.MsgActionNotSupported)
}
// Check for file upload
if r.Part == nil || r.Part.FileName() == "" {
return nil, i18n.NewError(r.Req.Context(), coremsgs.MsgMissingFileUpload)
}
data := &core.DataRefOrValue{}
validator := r.FP["validator"]
if len(validator) > 0 {
data.Validator = core.ValidatorType(validator)
}
if r.FP["datatype.name"] != "" {
data.Datatype = &core.DatatypeRef{
Name: r.FP["datatype.name"],
Version: r.FP["datatype.version"],
}
}
metadata := r.FP["metadata"]
if len(metadata) > 0 {
// The metadata might be JSON, or just a simple string. Try to unmarshal and see
var marshalCheck interface{}
if err := json.Unmarshal([]byte(metadata), &marshalCheck); err != nil {
metadata = fmt.Sprintf(`"%s"`, metadata)
}
data.Value = fftypes.JSONAnyPtr(metadata)
}
output, err = cr.or.Data().UploadBlob(cr.ctx, data, r.Part, strings.EqualFold(r.FP["autometa"], "true"))
return output, err
},
},
}
36 changes: 36 additions & 0 deletions internal/swagger/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Package swagger Code generated by swaggo/swag at 2025-10-10 07:17:54.1777731 +0530 IST m=+84.795132601. DO NOT EDIT
package swagger

import "github.com/swaggo/swag"

const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
7 changes: 7 additions & 0 deletions internal/swagger/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"swagger": "2.0",
"info": {
"contact": {}
},
"paths": {}
}
4 changes: 4 additions & 0 deletions internal/swagger/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
info:
contact: {}
paths: {}
swagger: "2.0"