openapi: '3.0.3'
info:
  title: API Title
  version: '1.0'

paths:
  /_IGNORE_PATH:
    get:
      responses:
        '200':
          description: OK

components:
  schemas:
    CompactJWS:
      title: CompactJWS
      type: string
      pattern: '^[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$'
    
    DataExchangeAgreement:
      type: object
      required:
      - orig
      - dest
      - encAlg
      - signingAlg
      - hashAlg
      - ledgerContractAddress
      - ledgerSignerAddress
      - pooToPorDelay
      - pooToPopDelay
      - pooToSecretDelay
      properties:
        orig:
          type: string
          description: "A stringified JWK with alphabetically sorted claims"
          example: '{"alg":"ES256","crv":"P-256","kty":"EC","x":"t0ueMqN9j8lWYa2FXZjSw3cycpwSgxjl26qlV6zkFEo","y":"rMqWC9jGfXXLEh_1cku4-f0PfbFa1igbNWLPzos_gb0"}'
        dest:
          type: string
          description: "A stringified JWK with alphabetically sorted claims"
          example: '{"alg":"ES256","crv":"P-256","kty":"EC","x":"sI5lkRCGpfeViQzAnu-gLnZnIGdbtfPiY7dGk4yVn-k","y":"4iFXDnEzPEb7Ce_18RSV22jW6VaVCpwH3FgTAKj3Cf4"}'
        encAlg:
          type: string
          enum: ['A128GCM', 'A256GCM']
          example: 'A256GCM'
        signingAlg:
          type: string
          enum: ['ES256', 'ES384', 'ES512']
          example: 'ES256'
        hashAlg:
          type: string
          enum: ['SHA-256', 'SHA-384', 'SHA-512']
          example: 'SHA-256'
        ledgerContractAddress:
          $ref: "./identity.yaml#/components/schemas/EthereumAddress"
        ledgerSignerAddress:
          $ref: "./identity.yaml#/components/schemas/EthereumAddress"
        pooToPorDelay:
          description: "Maximum acceptable time in milliseconds between issued PoO and verified PoR"
          type: integer
          minimum: 1
          example: 10000
        pooToPopDelay:
          description: "Maximum acceptable time in milliseconds between issued PoO and issued PoP"
          type: integer
          minimum: 1
          example: 20000
        pooToSecretDelay:
          description: "Maximum acceptable time between issued PoO and secret published on the ledger"
          type: integer
          minimum: 1
          example: 180000
        schema:
          description: "A stringified JSON-LD schema describing the data format" 
          type: string

    DataSharingAgreement:
      type: object
      required:
      - dataOfferingDescription
      - parties
      - purpose
      - duration
      - intendedUse
      - licenseGrant
      - dataStream
      - personalData
      - pricingModel
      - dataExchangeAgreement
      - signatures
      properties:
        dataOfferingDescription:
          type: object
          required:
          - dataOfferingId
          - version
          - active
          properties:
            dataOfferingId:
              type: string
            version:
              type: integer
            category:
              type: string
            active:
              type: boolean
            title:
              type: string
        parties:
          type: object
          required:
          - providerDid
          - consumerDid
          properties:
            providerDid:
              $ref: "./identity.yaml#/components/schemas/did"
            consumerDid:
              $ref: "./identity.yaml#/components/schemas/did"
        purpose:
          type: string
        duration:
          type: object
          required:
          - creationDate
          - startDate
          - endDate
          properties:
            creationDate:
              type: integer
            startDate:
              type: integer
            endDate:
              type: integer
        intendedUse:
          type: object
          required:
          - processData
          - shareDataWithThirdParty
          - editData
          properties:
            processData:
              type: boolean
            shareDataWithThirdParty:
              type: boolean
            editData:
              type: boolean
        licenseGrant:
          type: object
          required:
          - transferable
          - exclusiveness
          - paidUp
          - revocable
          - processing
          - modifying
          - analyzing
          - storingData
          - storingCopy
          - reproducing
          - distributing
          - loaning
          - selling
          - renting
          - furtherLicensing
          - leasing
          properties:
            transferable:
              type: boolean
            exclusiveness:
              type: boolean
            paidUp:
              type: boolean
            revocable:
              type: boolean
            processing:
              type: boolean
            modifying:
              type: boolean
            analyzing:
              type: boolean
            storingData:
              type: boolean
            storingCopy:
              type: boolean
            reproducing:
              type: boolean
            distributing:
              type: boolean
            loaning:
              type: boolean
            selling:
              type: boolean
            renting:
              type: boolean
            furtherLicensing:
              type: boolean
            leasing:
              type: boolean
        dataStream:
          type: boolean
        personalData:
          type: boolean
        pricingModel:
          type: object
          required:
          - basicPrice
          - currency
          - hasFreePrice
          properties:
            paymentType:
              type: string
            pricingModelName:
              type: string
            basicPrice:
              type: number
              format: float
            currency:
              type: string
            fee:
              type: number
              format: float
            hasPaymentOnSubscription:
              type: object
              properties:
                paymentOnSubscriptionName:
                  type: string
                paymentType:
                  type: string
                timeDuration:
                  type: string
                description:
                  type: string
                repeat:
                  type: string
                hasSubscriptionPrice:
                  type: number
            hasFreePrice:
              type: object
              properties:
                hasPriceFree:
                  type: boolean
        dataExchangeAgreement:
          $ref: "#/components/schemas/DataExchangeAgreement"
        signatures:
          type: object
          required:
          - providerSignature
          - consumerSignature
          properties:
            providerSignature:
              $ref: "#/components/schemas/CompactJWS"
            consumerSignature:
              $ref: "#/components/schemas/CompactJWS"
