Skip to content

Commit

Permalink
Add openapi docs for comment history api endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Mar 1, 2024
1 parent a886a0f commit be7d2b4
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/public/apidocs/OBS-v2.10.50.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ info:
For command-line users, we recommend using [osc](https://github.com/openSUSE/osc) with its _api_ command to interact with the API.
It's as simple as this example: `osc api /about` (_about_ is one of the endpoints documented below)
In order to make sure that the XML that is send in a requests body is in the expected format, the API validates it.
In order to make sure that the XML that is send in a requests body is in the expected format, the API validates it.
Either against a XML Schema Definition (`.xsd`) or a RELAX NG Schema (`.rng`). The schemas are mentioned
in the endpoint documentation. If there is no schema file mentioned, no validation of the XML is done.
In case the XML is not valid, a validation error is reported.
Expand Down Expand Up @@ -154,6 +154,8 @@ paths:

/comment/{comment_id}:
$ref: 'paths/comment_comment_id.yaml'
/comment/{comment_id}/history:
$ref: 'paths/comment_comment_id_history.yaml'
/comments/user:
$ref: 'paths/comments_user.yaml'
/comments/request/{id}:
Expand Down
12 changes: 12 additions & 0 deletions src/api/public/apidocs/components/schemas/comment_history.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
properties:
comment:
type: array
items:
$ref: 'comment.yaml'
comment:
type: integer
xml:
attribute: true
xml:
name: comment_history
52 changes: 52 additions & 0 deletions src/api/public/apidocs/paths/comment_comment_id_history.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
get:
summary: List the history of a comment
description: |
List the versions of a edited comment.
**(Beta/Unstable)** This endpoint is currently behind the `content_moderation` beta flag.
security:
- basic_authentication: []
parameters:
- in: path
name: comment_id
schema:
type: integer
required: true
description: Id of the comment.
example: 5
responses:
'200':
description: |
OK. The request has succeeded.
XML Schema used for body validation: [comment_history.rng](../schema/comment_history.rng)
content:
application/xml; charset=utf-8:
schema:
$ref: '../components/schemas/comment_history.yaml'
example: |
<comment_history comment="6">
<comment who="bar" when="2024-02-28 16:12:45 UTC" id="6">First version of comment</comment>
<comment who="bar" when="2024-02-28 16:15:27 UTC" id="6">UHH DONT LIKE MY COMMENT</comment>
</comment_history>
'401':
$ref: '../components/responses/unauthorized.yaml'
'403':
description: 'Forbidden'
content:
application/xml; charset=utf-8:
schema:
$ref: '../components/schemas/api_response.yaml'
example:
code: history_comment_not_authorized
summary: Sorry, you are not authorized to history this comment.
'404':
description: Not Found
content:
application/xml; charset=utf-8:
schema:
$ref: '../components/schemas/api_response.yaml'
example:
code: not_found
summary: Couldn't find Comment with 'id'=67
tags:
- Comments

0 comments on commit be7d2b4

Please sign in to comment.