mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Document and return JSON data for API errors (#6938)
This commit is contained in:
@@ -172,6 +172,14 @@ paths:
|
||||
},
|
||||
"managedBy": "odo"
|
||||
}
|
||||
'500':
|
||||
description: error getting the description of the component
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
example:
|
||||
message: "error getting the description of the component"
|
||||
|
||||
/component/command:
|
||||
post:
|
||||
@@ -198,6 +206,22 @@ paths:
|
||||
$ref: '#/components/schemas/GeneralSuccess'
|
||||
example:
|
||||
message: "push was successfully executed"
|
||||
'400':
|
||||
description: command name not supported
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
example:
|
||||
message: "command name 'unknown' not supported. Supported values are: \"push\""
|
||||
'429':
|
||||
description: a push operation is not possible at this time. Please retry later
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
example:
|
||||
message: "a push operation is not possible at this time. Please retry later"
|
||||
|
||||
components:
|
||||
schemas:
|
||||
|
||||
@@ -14,6 +14,7 @@ To see how to make this your own, look here:
|
||||
|
||||
- API version: 0.1
|
||||
|
||||
|
||||
### Running the server
|
||||
To run the server, follow these simple steps:
|
||||
|
||||
|
||||
@@ -57,7 +57,9 @@ func (s *DefaultApiService) ComponentCommandPost(ctx context.Context, componentC
|
||||
}
|
||||
|
||||
default:
|
||||
return openapi.Response(http.StatusBadRequest, nil), fmt.Errorf("command name %q not supported. Supported values are: %q", componentCommandPostRequest.Name, "push")
|
||||
return openapi.Response(http.StatusBadRequest, openapi.GeneralError{
|
||||
Message: fmt.Sprintf("command name %q not supported. Supported values are: %q", componentCommandPostRequest.Name, "push"),
|
||||
}), nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +67,9 @@ func (s *DefaultApiService) ComponentCommandPost(ctx context.Context, componentC
|
||||
func (s *DefaultApiService) ComponentGet(ctx context.Context) (openapi.ImplResponse, error) {
|
||||
value, _, err := describe.DescribeDevfileComponent(ctx, s.kubeClient, s.podmanClient, s.stateClient)
|
||||
if err != nil {
|
||||
return openapi.Response(http.StatusInternalServerError, ""), fmt.Errorf("error getting the description of the component: %w", err)
|
||||
return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{
|
||||
Message: fmt.Sprintf("error getting the description of the component: %s", err),
|
||||
}), nil
|
||||
}
|
||||
return openapi.Response(http.StatusOK, value), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user