commit 469487cc446ea358090d9681e91f976b5e2b388d
Author: Jan Pašek <pasekj@students.zcu.cz>
Date:   Thu Apr 22 14:47:34 2021 +0000

    Update swagger.yaml

diff --git a/src/swagger.yaml b/src/swagger.yaml
index 37e5740..c361efb 100644
--- a/src/swagger.yaml
+++ b/src/swagger.yaml
@@ -2,21 +2,75 @@ openapi: 3.0.0
 info:
   title: X.509 certificate management
   description: API for certificate management created for YOSO company
-  version: 1.0.1
+  version: 1.1.0
 servers:
-- url: https://virtserver.swaggerhub.com/janpasek97/X509_management/1.0.1
+- url: https://virtserver.swaggerhub.com/janpasek97/X509_management/1.1.0
   description: X509 management API
 tags:
 - name: certificates
   description: API for creating and querying certificates
 paths:
+  /api/certificates:
+    get:
+      tags:
+      - certificates
+      summary: get list of certificates
+      description: Lists certificates based on provided filtering options
+      operationId: getCertificateList
+      parameters:
+      - name: filtering
+        in: query
+        description: Filter certificate type to be queried
+        required: false
+        style: form
+        explode: true
+        schema:
+          $ref: '#/components/schemas/Filtering'
+      responses:
+        "200":
+          description: returning results matching filtering criteria
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/CertificateListResponse'
+        "400":
+          description: bad request
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
+    post:
+      tags:
+      - certificates
+      summary: create new certificate
+      description: Create a new certificate based on given information
+      operationId: createCertificate
+      requestBody:
+        description: Certificate data to be created
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/CertificateRequest'
+      responses:
+        "201":
+          description: item created
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/CreatedResponse'
+        "400":
+          description: invalid input, object invalid
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
   /api/certificates/{id}:
     get:
       tags:
       - certificates
       summary: get certificate by ID
       description: Get certificate in PEM format by ID
-      operationId: get_certificate_by_id
+      operationId: getCertificateById
       parameters:
       - name: id
         in: path
@@ -33,7 +87,7 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/PemResponse'
-        "204":
+        "404":
           description: the certificate was not found
           content:
             application/json:
@@ -45,14 +99,86 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
+    delete:
+      tags:
+      - certificates
+      summary: delete certificate by ID
+      description: Delete certificate by id. If the specified certificate is an issuer of some other certificate, whole subtree is delted.
+      operationId: deleteCertificateById
+      parameters:
+      - name: id
+        in: path
+        description: ID of a certificate to be deleted
+        required: true
+        style: simple
+        explode: false
+        schema:
+          $ref: '#/components/schemas/IdParameter'
+      responses:
+        "200":
+          description: certificate deleted
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/SuccessResponse'
+        "400":
+          description: bad request
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
+        "404":
+          description: Certificate was not found
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
+    patch:
+      tags:
+      - certificates
+      summary: revoke certificate by id
+      description: Revoke a certificate specified by id
+      operationId: revokeCertificateById
+      parameters:
+      - name: id
+        in: path
+        description: ID of a certificate to be deleted
+        required: true
+        style: simple
+        explode: false
+        schema:
+          $ref: '#/components/schemas/IdParameter'
+      requestBody:
+        content:
+          application/json:
+            schema:
+              $ref: '#/components/schemas/SetStatusRequest'
+      responses:
+        "200":
+          description: Certificate status updated
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/SuccessResponse'
+        "400":
+          description: bad request
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
+        "404":
+          description: Certificate was not found
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/ErrorResponse'
   /api/certificates/{id}/chain:
     get:
       tags:
       - certificates
       summary: get certificate's trust chain by ID
       description: Get certificate trust chain in PEM format by ID
-      operationId: get_certificate_trust_chain_by_id
+      operationId: getCertificateTrustChainById
       parameters:
       - name: id
         in: path
@@ -69,7 +195,7 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/PemResponse'
-        "204":
+        "404":
           description: the certificate was not found
           content:
             application/json:
@@ -81,14 +207,13 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
   /api/certificates/{id}/root:
     get:
       tags:
       - certificates
       summary: get certificate's root of trust chain by ID
       description: Get certificate's root of trust chain in PEM format by ID
-      operationId: get_certificate_root_by_id
+      operationId: getCertificateRootById
       parameters:
       - name: id
         in: path
@@ -105,7 +230,7 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/PemResponse'
-        "204":
+        "404":
           description: the certificate was not found
           content:
             application/json:
@@ -117,14 +242,13 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
   /api/certificates/{id}/details:
     get:
       tags:
       - certificates
       summary: get certificate's details by ID
       description: Get certificate details by ID
-      operationId: get_certificate_details_by_id
+      operationId: getCertificateDetailsById
       parameters:
       - name: id
         in: path
@@ -141,7 +265,7 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/CertificateResponse'
-        "204":
+        "404":
           description: the certificate was not found
           content:
             application/json:
@@ -153,32 +277,31 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
-  /api/certificates:
+  /api/certificates/{id}/publickey:
     get:
       tags:
       - certificates
-      summary: get list of certificates
-      description: Lists certificates based on provided filtering options
-      operationId: get_certificate_list
+      summary: get public key of given certificate
+      description: Get public key that belongs to the selected certificate
+      operationId: getPublicKeyOfCertificateById
       parameters:
-      - name: filtering
-        in: query
-        description: Filter certificate type to be queried
-        required: false
-        style: form
-        explode: true
+      - name: id
+        in: path
+        description: ID of a certificate whose public key is to be queried
+        required: true
+        style: simple
+        explode: false
         schema:
-          $ref: '#/components/schemas/Filtering'
+          $ref: '#/components/schemas/IdParameter'
       responses:
         "200":
-          description: returning results matching filtering criteria
+          description: returning the certificate's public key
           content:
             application/json:
               schema:
-                $ref: '#/components/schemas/CertificateListResponse'
-        "204":
-          description: no certificates found
+                $ref: '#/components/schemas/PemResponse'
+        "404":
+          description: the certificate was not found
           content:
             application/json:
               schema:
@@ -189,39 +312,41 @@ paths:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
-    post:
+  /api/certificates/{id}/privatekey:
+    get:
       tags:
       - certificates
-      summary: create new certificate
-      description: Create a new certificate based on given information
-      operationId: create_certificate
-      requestBody:
-        description: Certificate data to be created
-        content:
-          application/json:
-            schema:
-              $ref: '#/components/schemas/CertificateRequest'
+      summary: get private key of given certificate
+      description: Get private key that belongs to the selected certificate
+      operationId: getPrivateKeyOfCertificateById
+      parameters:
+      - name: id
+        in: path
+        description: ID of a certificate whose private key is to be queried
+        required: true
+        style: simple
+        explode: false
+        schema:
+          $ref: '#/components/schemas/IdParameter'
       responses:
-        "201":
-          description: item created
+        "200":
+          description: returning the certificate's private key
           content:
             application/json:
               schema:
-                $ref: '#/components/schemas/CreatedResponse'
-        "400":
-          description: "invalid input, object invalid"
+                $ref: '#/components/schemas/PemResponse'
+        "404":
+          description: the certificate was not found
           content:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-        "409":
-          description: an existing item already exists
+        "400":
+          description: bad request
           content:
             application/json:
               schema:
                 $ref: '#/components/schemas/ErrorResponse'
-      x-openapi-router-controller: swagger_server.controllers.certificates_controller
 components:
   schemas:
     CAUsage:
@@ -239,11 +364,6 @@ components:
           type: boolean
         SSL:
           type: boolean
-      example:
-        digitalSignature: true
-        SSL: true
-        CA: true
-        authentication: true
     IssuerListItem:
       required:
       - CN
@@ -255,9 +375,6 @@ components:
         CN:
           type: string
           example: Root CA s.r.o.
-      example:
-        id: 547
-        CN: Root CA s.r.o.
     CertificateListResponse:
       properties:
         success:
@@ -267,33 +384,6 @@ components:
           type: array
           items:
             $ref: '#/components/schemas/CertificateListItem'
-      example:
-        data:
-        - notAfter: 2021-07-01T00:00:00.000+00:00
-          usage:
-            digitalSignature: true
-            SSL: true
-            CA: true
-            authentication: true
-          id: 547
-          CN: Root CA s.r.o.
-          notBefore: 2021-03-31T00:00:00.000+00:00
-          issuer:
-            id: 547
-            CN: Root CA s.r.o.
-        - notAfter: 2021-07-01T00:00:00.000+00:00
-          usage:
-            digitalSignature: true
-            SSL: true
-            CA: true
-            authentication: true
-          id: 547
-          CN: Root CA s.r.o.
-          notBefore: 2021-03-31T00:00:00.000+00:00
-          issuer:
-            id: 547
-            CN: Root CA s.r.o.
-        success: true
     CertificateListItem:
       properties:
         id:
@@ -314,23 +404,13 @@ components:
           $ref: '#/components/schemas/CAUsage'
         issuer:
           $ref: '#/components/schemas/IssuerListItem'
-      example:
-        notAfter: 2021-07-01T00:00:00.000+00:00
-        usage:
-          digitalSignature: true
-          SSL: true
-          CA: true
-          authentication: true
-        id: 547
-        CN: Root CA s.r.o.
-        notBefore: 2021-03-31T00:00:00.000+00:00
-        issuer:
-          id: 547
-          CN: Root CA s.r.o.
     Filtering:
       properties:
         CA:
           type: boolean
+        issuedby:
+          type: integer
+          example: 517
     Subject:
       required:
       - CN
@@ -363,14 +443,6 @@ components:
           type: string
           description: Email Address
           example: root@ca.com
-      example:
-        ST: Pilsen Region
-        emailAddress: root@ca.com
-        C: CZ
-        OU: IT department
-        CN: Root CA s.r.o.
-        L: Pilsen
-        O: Root CA s.r.o.
     Certificate:
       required:
       - notAfter
@@ -394,23 +466,6 @@ components:
           type: integer
           description: ID of the new item
           example: 547
-      example:
-        notAfter: 2021-07-01T00:00:00.000+00:00
-        subject:
-          ST: Pilsen Region
-          emailAddress: root@ca.com
-          C: CZ
-          OU: IT department
-          CN: Root CA s.r.o.
-          L: Pilsen
-          O: Root CA s.r.o.
-        usage:
-          digitalSignature: true
-          SSL: true
-          CA: true
-          authentication: true
-        notBefore: 2021-03-31T00:00:00.000+00:00
-        CA: 547
     CertificateRequest:
       required:
       - subject
@@ -423,11 +478,30 @@ components:
           type: integer
           example: 30
         usage:
-          $ref: '#/components/schemas/CAUsage'
+          type: array
+          items:
+            type: string
+            enum:
+            - CA
+            - authentication
+            - digitalSignature
+            - SSL
         CA:
           type: integer
           description: ID of the new item
           example: 547
+    SuccessResponse:
+      required:
+      - data
+      - success
+      properties:
+        success:
+          type: boolean
+          example: true
+        data:
+          type: string
+          example: Operation was successfull
+      description: Operation successfull
     CreatedResponse:
       required:
       - data
@@ -440,9 +514,6 @@ components:
           type: integer
           example: 457
       description: Item was created
-      example:
-        data: 457
-        success: true
     ErrorResponse:
       required:
       - data
@@ -464,25 +535,6 @@ components:
           example: true
         data:
           $ref: '#/components/schemas/Certificate'
-      example:
-        data:
-          notAfter: 2021-07-01T00:00:00.000+00:00
-          subject:
-            ST: Pilsen Region
-            emailAddress: root@ca.com
-            C: CZ
-            OU: IT department
-            CN: Root CA s.r.o.
-            L: Pilsen
-            O: Root CA s.r.o.
-          usage:
-            digitalSignature: true
-            SSL: true
-            CA: true
-            authentication: true
-          notBefore: 2021-03-31T00:00:00.000+00:00
-          CA: 547
-        success: true
     PemResponse:
       required:
       - data
@@ -493,14 +545,8 @@ components:
           example: true
         data:
           type: string
-          description: Single PEM file or concatenation of multiple PEM formatted
-            certificates
-          example: '-----BEGIN CERTIFICATE-----MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQ...etc-----END
-            CERTIFICATE-----'
-      example:
-        data: '-----BEGIN CERTIFICATE-----MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQ...etc-----END
-          CERTIFICATE-----'
-        success: true
+          description: Single PEM file or concatenation of multiple PEM formatted certificates
+          example: '-----BEGIN CERTIFICATE-----MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQ...etc-----END CERTIFICATE-----'
     IdParameter:
       required:
       - id
@@ -508,4 +554,23 @@ components:
         id:
           type: integer
           example: 444
-
+    SetStatusRequest:
+      required:
+      - status
+      properties:
+        status:
+          type: string
+          enum:
+          - revoked
+          - valid
+        reason:
+          type: string
+          enum:
+          - unspecified
+          - keyCompromise
+          - CACompromise
+          - affiliationChanged
+          - superseded
+          - cessationOfOperation
+          - certificateHold
+          - removeFromCRL
