diff --git a/api/grpc.yaml b/api/grpc.yaml index ab4293a7d8..912e66dca0 100644 --- a/api/grpc.yaml +++ b/api/grpc.yaml @@ -31,9 +31,12 @@ components: GRPCResponse: type: object + required: + - statusCode properties: statusCode: type: integer + default: 0 metadata: type: array items: diff --git a/cli/openapi/model_grpc_response.go b/cli/openapi/model_grpc_response.go index e11df866e0..beb725ff07 100644 --- a/cli/openapi/model_grpc_response.go +++ b/cli/openapi/model_grpc_response.go @@ -19,7 +19,7 @@ var _ MappedNullable = &GRPCResponse{} // GRPCResponse struct for GRPCResponse type GRPCResponse struct { - StatusCode *int32 `json:"statusCode,omitempty"` + StatusCode int32 `json:"statusCode"` Metadata []GRPCHeader `json:"metadata,omitempty"` Body *string `json:"body,omitempty"` } @@ -28,8 +28,9 @@ type GRPCResponse struct { // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewGRPCResponse() *GRPCResponse { +func NewGRPCResponse(statusCode int32) *GRPCResponse { this := GRPCResponse{} + this.StatusCode = statusCode return &this } @@ -38,39 +39,33 @@ func NewGRPCResponse() *GRPCResponse { // but it doesn't guarantee that properties required by API are set func NewGRPCResponseWithDefaults() *GRPCResponse { this := GRPCResponse{} + var statusCode int32 = 0 + this.StatusCode = statusCode return &this } -// GetStatusCode returns the StatusCode field value if set, zero value otherwise. +// GetStatusCode returns the StatusCode field value func (o *GRPCResponse) GetStatusCode() int32 { - if o == nil || isNil(o.StatusCode) { + if o == nil { var ret int32 return ret } - return *o.StatusCode + + return o.StatusCode } -// GetStatusCodeOk returns a tuple with the StatusCode field value if set, nil otherwise +// GetStatusCodeOk returns a tuple with the StatusCode field value // and a boolean to check if the value has been set. func (o *GRPCResponse) GetStatusCodeOk() (*int32, bool) { - if o == nil || isNil(o.StatusCode) { + if o == nil { return nil, false } - return o.StatusCode, true -} - -// HasStatusCode returns a boolean if a field has been set. -func (o *GRPCResponse) HasStatusCode() bool { - if o != nil && !isNil(o.StatusCode) { - return true - } - - return false + return &o.StatusCode, true } -// SetStatusCode gets a reference to the given int32 and assigns it to the StatusCode field. +// SetStatusCode sets field value func (o *GRPCResponse) SetStatusCode(v int32) { - o.StatusCode = &v + o.StatusCode = v } // GetMetadata returns the Metadata field value if set, zero value otherwise. @@ -147,9 +142,7 @@ func (o GRPCResponse) MarshalJSON() ([]byte, error) { func (o GRPCResponse) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !isNil(o.StatusCode) { - toSerialize["statusCode"] = o.StatusCode - } + toSerialize["statusCode"] = o.StatusCode if !isNil(o.Metadata) { toSerialize["metadata"] = o.Metadata } diff --git a/server/openapi/model_grpc_response.go b/server/openapi/model_grpc_response.go index 70350f9bc4..a2500a9970 100644 --- a/server/openapi/model_grpc_response.go +++ b/server/openapi/model_grpc_response.go @@ -10,7 +10,7 @@ package openapi type GrpcResponse struct { - StatusCode int32 `json:"statusCode,omitempty"` + StatusCode int32 `json:"statusCode"` Metadata []GrpcHeader `json:"metadata,omitempty"` @@ -19,6 +19,15 @@ type GrpcResponse struct { // AssertGrpcResponseRequired checks if the required fields are not zero-ed func AssertGrpcResponseRequired(obj GrpcResponse) error { + elements := map[string]interface{}{ + "statusCode": obj.StatusCode, + } + for name, el := range elements { + if isZero := IsZeroValue(el); isZero { + return &RequiredError{Field: name} + } + } + for _, el := range obj.Metadata { if err := AssertGrpcHeaderRequired(el); err != nil { return err diff --git a/web/src/models/TriggerResult.model.ts b/web/src/models/TriggerResult.model.ts index 23df2a316a..626a9f4262 100644 --- a/web/src/models/TriggerResult.model.ts +++ b/web/src/models/TriggerResult.model.ts @@ -24,7 +24,7 @@ const ResponseData = { return { body: get(response, 'body', ''), headers: get(response, 'metadata', undefined) as THeader[], - statusCode: get(response, 'statusCode', 200), + statusCode: get(response, 'statusCode', 0), }; }, [TriggerTypes.traceid](response: object) { @@ -38,7 +38,7 @@ const ResponseData = { const TriggerResult = ({ triggerType = 'http', - triggerResult: {http = {}, grpc = {}, traceid = {}} = {}, + triggerResult: {http = {}, grpc = {statusCode: 0}, traceid = {}} = {}, }: TRawTriggerResult): TriggerResult => { const type = triggerType as TriggerTypes; diff --git a/web/src/types/Generated.types.ts b/web/src/types/Generated.types.ts index 71fb23991c..2d631c60e8 100644 --- a/web/src/types/Generated.types.ts +++ b/web/src/types/Generated.types.ts @@ -1565,7 +1565,7 @@ export interface external { request?: string; }; GRPCResponse: { - statusCode?: number; + statusCode: number; metadata?: external["grpc.yaml"]["components"]["schemas"]["GRPCHeader"][]; body?: string; };