Text Generation
Transformers
English
mixtral
legal
conversational
Inference Endpoints
File size: 25,100 Bytes
30e605a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
openapi: 3.0.0
info:
  description: Context aware, pluggable and customizable PII anonymization service for text and images.
  version: "2.0"
  title: Presidio
  contact:
    name: Presidio support
    email: [email protected]
    url: https://github.com/microsoft/presidio
  x-logo:
    url: "https://upload.wikimedia.org/wikipedia/commons/4/44/Microsoft_logo.svg"
  license:
    name: MIT
    url: 'https://github.com/microsoft/presidio/blob/main/LICENSE'
externalDocs:
  description: Presidio documentation.
  url: 'https://microsoft.github.io/presidio/'
tags:
  - name: Analyzer
    description: Detecting PII entities in text
  - name: Anonymizer
    description: Anonymizing detected PII text entities with desired values.

paths:

  /analyze:
    post:
      servers:
        - url: https://presidio-analyzer-prod.azurewebsites.net
      tags:
        - Analyzer
      summary: "Analyze Text"
      description: "Recognizes PII entities in a given text and returns their types, locations and score"
      requestBody:
        $ref: "#/components/requestBodies/AnalyzeRequest"

      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                description: "A list analysis results"
                type: array
                items:
                  $ref: "#/components/schemas/RecognizerResultWithAnaysisExplanation"

              examples:
                Enhanced response:
                  value:
                    [
                      { "entity_type": "PERSON", "start": 0, "end": 10, "score": 0.85,
                        "analysis_explanation": {
                          "recognizer": "SpacyRecognizer", "pattern_name": null, "pattern": null, "original_score": 0.85,
                          "score": 0.85, "textual_explanation": "Identified as PERSON by Spacy's Named Entity Recognition",
                          "score_context_improvement": 0, "supportive_context_word": "", "validation_result": null
                        },
                        "recognition_metadata": {
                          "recognizer_name": "SpacyRecognizer"
                        }
                      },
                      { "entity_type": "US_DRIVER_LICENSE", "start": 30, "end": 38, "score": 0.6499999999999999,
                        "analysis_explanation": {
                          "recognizer": "UsLicenseRecognizer", "pattern_name": "Driver License - Alphanumeric (weak)",
                          "pattern": "\\\\b([A-Z][0-9]{3,6}|[A-Z][0-9]{5,9}|[A-Z][0-9]{6,8}|[A-Z][0-9]{4,8}|[A-Z][0-9]{9,11}|[A-Z]{1,2}[0-9]{5,6}|H[0-9]{8}|V[0-9]{6}|X[0-9]{8}|A-Z]{2}[0-9]{2,5}|[A-Z]{2}[0-9]{3,7}|[0-9]{2}[A-Z]{3}[0-9]{5,6}|[A-Z][0-9]{13,14}|[A-Z][0-9]{18}|[A-Z][0-9]{6}R|[A-Z][0-9]{9}|[A-Z][0-9]{1,12}|[0-9]{9}[A-Z]|[A-Z]{2}[0-9]{6}[A-Z]|[0-9]{8}[A-Z]{2}|[0-9]{3}[A-Z]{2}[0-9]{4}|[A-Z][0-9][A-Z][0-9][A-Z]|[0-9]{7,8}[A-Z])\\\\b",
                          "original_score": 0.3, "score": 0.6499999999999999, "textual_explanation": null,
                          "score_context_improvement": 0.3499999999999999, "supportive_context_word": "driver",
                          "validation_result": null
                        },
                        "recognition_metadata": {
                          "recognizer_name": "UsLicenseRecognizer"
                        }
                      }
                    ]
                Lean response:
                  value:
                    [
                      {
                        "analysis_explanation": null,
                        "end": 38,
                        "entity_type": "US_DRIVER_LICENSE",
                        "score": 0.6499999999999999,
                        "start": 30,
                        "recognition_metadata": {
                          "recognizer_name": "UsLicenseRecognizer"
                        }
                      }
                    ]

  /recognizers:
    get:
      servers:
        - url: https://presidio-analyzer-prod.azurewebsites.net
      tags:
        - Analyzer
      summary: "Get Recognizers"
      description: "Get the available PII recognizers for a given language"
      parameters:
        - in: query
          name: language
          schema:
            type: string
            example: en
          description: "Two characters for the desired language in ISO_639-1 format"
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                description: "A list of supported recognizers"
                type: array
                items:
                  type: string
                  description: "Recognizer name"
              example:
                [
                    "CryptoRecognizer", "CreditCardRecognizer", "IbanRecognizer", "UsPhoneRecognizer",
                    "EmailRecognizer","UsPassportRecognizer", "NhsRecognizer", "IpRecognizer",
                    "SpacyRecognizer","SgFinRecognizer", "UsSsnRecognizer","UsBankRecognizer",
                    "DomainRecognizer", "UsLicenseRecognizer", "UsItinRecognizer"
                ]

  /supportedentities:
    get:
      servers:
        - url: https://presidio-analyzer-prod.azurewebsites.net
      tags:
        - Analyzer
      summary: "Get supported entities"
      description: "Get the list of PII entities Presidio-Analyzer is capable of detecting"
      parameters:
        - in: query
          name: language
          schema:
            type: string
            example: en
          description: "Two characters for the desired language in ISO_639-1 format"
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                description: "A list of supported entities"
                type: array
                items:
                  $ref: "#/components/schemas/EntityTypes"
              example:
                [ "PHONE_NUMBER", "US_DRIVER_LICENSE", "US_PASSPORT", "LOCATION", "CREDIT_CARD", "CRYPTO",
                  "UK_NHS", "US_SSN", "US_BANK_NUMBER", "EMAIL_ADDRESS", "DATE_TIME", "IP_ADDRESS", "PERSON", "IBAN_CODE",
                  "NRP", "US_ITIN", "MEDICAL_LICENSE", "URL" ]

  /anonymize:
    post:
      servers:
        - url: https://presidio-anonymizer-prod.azurewebsites.net
      tags:
        - Anonymizer
      summary: "Anonymize Text"
      requestBody:
        $ref: "#/components/requestBodies/AnonymizeRequest"

      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AnonymizeResponse"
              examples:
                Replace and Redact Anonymizers:
                  value:
                    { "text": "hello world, my name is ANONYMIZED. My number is: ", "items": [ { "operator": "redact", "entity_type": "PHONE_NUMBER", "start": 50, "end": 50, "text": "" }, { "operator": "replace", "entity_type": "NAME", "start": 24, "end": 34, "text": "ANONYMIZED" } ] }
                Replace as default Anonymizer:
                  value:
                    { "text": "hello world, my name is ANONYMIZED. My number is: ANONYMIZED", "items": [ { "operator": "replace", "entity_type": "PHONE_NUMBER", "start": 50, "end": 60, "text": "ANONYMIZED" }, { "operator": "replace", "entity_type": "NAME", "start": 24, "end": 34, "text": "ANONYMIZED" } ] }
        400:
          $ref: "#/components/responses/400BadRequest"

        422:
          $ref: "#/components/responses/422UnprocessableEntity"

  /anonymizers:
    get:
      servers:
        - url: https://presidio-anonymizer-prod.azurewebsites.net
      tags:
        - Anonymizer
      summary: "Get supported anonymizers"

      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                description: "A list of all built-in supported anonymizers"
                type: array
                items:
                  description: "The Anonymizer name"
                  type: string
                  example: "mask"
              example:
                [ "hash", "mask", "redact", "replace", "encrypt" ]


  /deanonymize:
    post:
      servers:
        - url: https://presidio-anonymizer-prod.azurewebsites.net
      tags:
        - Anonymizer
      summary: "Deanonymize Text"
      requestBody:
        $ref: "#/components/requestBodies/DeanonymizeRequest"

      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeanonymizeResponse"
              examples:
                Decrypt Single PII:
                  value:
                    { "text": "text_for_encryption", "items": [ { "start": 0, "end": 19, "operator":"decrypt", "text": "text_for_encryption","entity_type": "NUMBER" } ] }
        400:
          $ref: "#/components/responses/400BadRequest"

        422:
          $ref: "#/components/responses/422UnprocessableEntity"

  /deanonymizers:
    get:
      servers:
        - url: https://presidio-anonymizer-prod.azurewebsites.net
      tags:
        - Anonymizer
      summary: "Get supported deanonymizers"

      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                description: "A list of all built-in supported deanonymizers"
                type: array
                items:
                  description: "The Deanonymizer name"
                  type: string
                  example: "decrypt"
              example:
                [ "decrypt" ]

  /health:
    get:
      servers:
        - url: https://presidio-anonymizer-prod.azurewebsites.net
      tags:
        - Anonymizer
        - Analyzer
      summary: "Healthcheck"
      responses:
        200:
          description: OK
          content:
            text/plain:
              schema:
                type: string
                example: Presidio Anonymizer service is up

components:
  requestBodies:
    AnalyzeRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AnalyzeRequest"
          examples:
            Minimal Request:
              value:
                {
                  "text": "John Smith drivers license is AC432223",
                  "language": "en"
                }
            Enhanced Request :
              value:
                {
                  "text": "John Smith drivers license is AC432223 and the zip code is 12345",
                  "language": "en",
                  "return_decision_process": false,
                  "correlation_id": "123e4567-e89b-12d3-a456-426614174000",
                  "score_threshold": 0.6,
                  "entities": ["US_DRIVER_LICENSE", "ZIP"],
                  "trace": false,
                  "ad_hoc_recognizers":[
                    {
                    "name": "Zip code Recognizer",
                    "supported_language": "en",
                    "patterns": [
                        {
                        "name": "zip code (weak)", 
                        "regex": "(\\b\\d{5}(?:\\-\\d{4})?\\b)", 
                        "score": 0.01
                        }
                    ],
                    "context": ["zip", "code"],
                    "supported_entity":"ZIP"
                    }
                  ]
                }

    AnonymizeRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AnonymizeRequest"
          examples:
            Replace and Redact Anonymizers:
              value:
                {
                  "text": "hello world, my name is Jane Doe. My number is: 034453334",
                  "anonymizers": {
                    "PERSON": { "type": "redact" },
                    "PHONE_NUMBER": { "type": "replace", "new_value": "ANONYMIZED" }
                  },
                  "analyzer_results": [
                    { "start": 24, "end": 32, "score": 0.8, "entity_type": "PERSON" },
                    { "start": 48, "end": 57,  "score": 0.95, "entity_type": "PHONE_NUMBER" }
                  ]
                }
            Replace as default Anonymizer:
              value:
                {
                  "text": "hello world, my name is Jane Doe.",
                  "anonymizers": {
                    "DEFAULT": { "type": "replace", "new_value": "ANONYMIZED" },
                  },
                  "analyzer_results": [
                    { "start": 24, "end": 32, "score": 0.8, "entity_type": "PERSON" },
                  ]
                }

    DeanonymizeRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/DeanonymizeRequest"
          examples:
            Deanonymize text:
              value:
                {
                  "text": "My name is S184CMt9Drj7QaKQ21JTrpYzghnboTF9pn/neN8JME0=",
                  "deanonymizers": {
                    "PERSON": {
                      "type": "decrypt",
                      "key": "WmZq4t7w!z%C&F)J"
                    }
                  },
                  "anonymizer_results": [ {
                    "start": 11,
                    "end": 55,
                    "entity_type": "PERSON"
                  } ]
                }


  schemas:
    AnalyzeRequest:
      type: object
      required:
        - text
        - language
      properties:
        text:
          type: string
          description: "The text to analyze"
          example: "hello world, my name is Jane Doe. My number is: 034453334"
        language:
          type: string
          description: "Two characters for the desired language in ISO_639-1 format"
          example: "en"
        correlation_id:
          type: string
          description: "A correlation id to append to headers and traces"
        score_threshold:
          type: number
          format: double
          description: "The minimal detection score threshold"
        entities:
          type: array
          items:
            $ref: "#/components/schemas/EntityTypes"
          description: "A list of entities to analyze"
        return_decision_process:
          type: boolean
          description: "Whether to include analysis explanation in the response"
        ad_hoc_recognizers:
          type: array
          description: "list of recognizers to be used in the context of this request only (ad-hoc)."
          items:
            $ref: "#/components/schemas/PatternRecognizer"
        context:
          type: array
          description: "list of context words which may help to raise recognized entities confidence"
          items:
            description: "The context word"
            type: string
            example: "address"

    AnonymizeRequest:
      type: object
      required:
        - text
        - analyzer_results
      properties:
        text:
          type: string
          description: "The text to anonymize"
          example: "hello world, my name is Jane Doe. My number is: 034453334"
        anonymizers:
          description: "Object where the key is DEFAULT or the ENTITY_TYPE and the value is the anonymizer definition"
          type: object
          additionalProperties:
            anyOf:
              - $ref: "#/components/schemas/Replace"
              - $ref: "#/components/schemas/Redact"
              - $ref: "#/components/schemas/Mask"
              - $ref: "#/components/schemas/Hash"
              - $ref: "#/components/schemas/Encrypt"
          default:
            { "DEFAULT": { "type": "replace", "new_value": "<ENTITY_TYPE>" } }

        analyzer_results:
          type: array
          description: "Array of analyzer detections"
          items:
            $ref: "#/components/schemas/RecognizerResult"

    DeanonymizeRequest:
      type: object
      required:
        - text
        - anonymizer_results
        - deanonymizers
      properties:
        text:
          type: string
          description: "The anonymized text"
          example: "My name is S184CMt9Drj7QaKQ21JTrpYzghnboTF9pn/neN8JME0="
        deanonymizers:
          description: "Object where the key is DEFAULT or the ENTITY_TYPE and the value is decrypt since it is the only one supported"
          type: object
          additionalProperties:
            anyOf:
              - $ref: "#/components/schemas/Decrypt"
          default:
            { "DEFAULT": { "type": "decrypt", "key": "3t6w9z$C&F)J@NcR" } }
        anonymizer_results:
          type: array
          description: "Array of anonymized PIIs"
          items:
            $ref: "#/components/schemas/OperatorResult"


    RecognizerResult:
      type: object
      required:
        - start
        - end
        - score
        - entity_type
      properties:
        start:
          type: integer
          description: "Where the PII starts"
          example: 24
        end:
          type: integer
          description: "Where the PII ends"
          example: 32
        score:
          type: number
          format: double
          description: "The PII detection score"
          example: 0.8
        entity_type:
          $ref: "#/components/schemas/EntityTypes"
        recognition_metadata:
          type: object
          $ref: "#/components/schemas/RecognizedMetadata"

    RecognizedMetadata:
      type: object
      properties:
        recognizer_name:
          type: string
          description: "Name of recognizer that made the decision"

    RecognizerResultWithAnaysisExplanation:
      allOf:
        - $ref: '#/components/schemas/RecognizerResult'
        - type: object
          properties:
            analysis_explanation:
              $ref: "#/components/schemas/AnalysisExplanation"

    AnalysisExplanation:
      type: object
      properties:
        recognizer:
          type: string
          description: "Name of recognizer that made the decision"
        pattern_name:
          type: string
          description: "name of pattern (if decision was made by a PatternRecognizer)"
        pattern:
          type: string
          description: "Regex pattern that was applied (if PatternRecognizer)"
        original_score:
          type: number
          format: double
          description: "Recognizer's confidence in result"
        score:
          type: number
          format: double
          description: "The PII detection score"
        textual_explanation:
          type: string
          description: "Free text for describing a decision of a logic or model"
        score_context_improvement:
          type: number
          format: double
          description: "Difference from the original score"
        supportive_context_word:
          type: string
          description: "The context word which helped increase the score"
        validation_result:
          type: number
          format: double
          description: "Result of a validation (e.g. checksum)"
    
    Pattern:
      type: object
      properties:
        name:
          type: string
          description: "Name of regular expression pattern"
        regex:
          type: string
          description: "Regex pattern string"
        score:
          type: number
          format: double
          description: "Detection confidence of this pattern (0.01 if very noisy, 0.6-1.0 if very specific)"


    PatternRecognizer:
      type: object
      description: "A regular expressions or deny-list based recognizer"
      properties:
        name:
          type: string
          description: "Name of recognizer"
        supported_language:
          type: string
          description: "Language code supported by this recognizer"
        patterns:
          description: "List of type Pattern containing regex expressions with additional metadata."
          type: array
          items:
            $ref: "#/components/schemas/Pattern"
        deny_list:
          type: array
          description: "List of words to be returned as PII if found."
          items:
            type: string
        context:
          description: "List of words to be used to increase confidence if found in the vicinity of detected entities."
          type: array
          items:
            type: string
        supported_entity:
          type: string
          description: "The name of entity this ad hoc recognizer detects"

    EntityTypes:
      description: "The supported PII entity types."
      type: string
      example: PERSON

    Replace:
      title: Replace
      description: "Replace with a given value"
      type: object
      required:
        - type
        - new_value
      properties:
        type:
          type: string
          description: "replace"
          example: replace
        new_value:
          type: string
          description: "The string to replace with"
          example: VALUE

    Redact:
      title: Redact
      description: "Replace with an empty string"
      type: object
      required:
        - type
      properties:
        type:
          type: string
          description: "redact"
          example: redact

    Mask:
      title: Mask
      description: "Replace with a given character"
      type: object
      required:
        - type
        - masking_char
        - chars_to_mask
      properties:
        type:
          type: string
          description: "mask"
          example: mask
        masking_char:
          type: string
          description: "The replacement character"
          example: "*"
        chars_to_mask:
          type: integer
          description: "The amount of characters that should be replaced"
          example: 4
        from_end:
          type: boolean
          description: "Whether to mask the PII from it's end"
          example: true
          default: false

    Hash:
      title: Hash
      description: "Replace with hashed value"
      type: object
      required:
        - type
      properties:
        type:
          type: string
          description: "hash"
          example: hash
        hash_type:
          type: string
          description: "The hashing algorithm"
          enum:
            - md5
            - sha256
            - sha512
          example: md5
          default: md5

    Encrypt:
      title: Encrypt
      description: "Replace with an encrypted value"
      type: object
      required:
        - type
        - key
      properties:
        type:
          type: string
          description: "encrypt"
          example: encrypt
        key:
          type: string
          description: "Cryptographic key of length 128, 192 or 256 bits, in a string format"
          example: "3t6w9z$C&F)J@NcR"

    Decrypt:
      title: Decrypt
      description: "Replace encrypted PII decrypted text"
      type: object
      required:
        - type
        - key
      properties:
        type:
          type: string
          description: "decrypt"
          example: decrypt
        key:
          type: string
          description: "Cryptographic key of length 128, 192 or 256 bits, in a string format"
          example: "3t6w9z$C&F)J@NcR"

    AnonymizeResponse:
      type: object
      properties:
        text:
          type: string
        items:
          type: array
          description: "Array of anonymized entities"
          items:
            $ref: "#/components/schemas/OperatorResult"

    OperatorResult:
      required:
        - start
        - end
        - entity_type
      type: object
      properties:
        operator:
          type: string
          description: "Name of the used operator"
        entity_type:
          type: string
          description: "Type of the PII entity"
        start:
          type: integer
          description: "Start index of the changed text"
        end:
          type: integer
          description: "End index in the changed text"
        text:
          type: string
          description: "The new text returned"

    DeanonymizeResponse:
      type: object
      properties:
        text:
          type: string
        items:
          type: array
          description: "Array of deanonymized entities"
          items:
            $ref: "#/components/schemas/OperatorResult"

  responses:
    400BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: "Invalid request json"

    422UnprocessableEntity:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: "Invalid input, text can not be empty"