feat(contract): add routing + normalization operationIds (ADR-027) #118
@@ -367,6 +367,60 @@ paths:
|
||||
$ref: "#/components/schemas/ProvenanceRecord"
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
/v1/0pt/parsing/route:
|
||||
post:
|
||||
operationId: 0pt.route_parsing
|
||||
summary: >
|
||||
(TARGET) Parser-routing/selektiv OCR-beslut (BTI-DOC-02/03/04/05).
|
||||
Kontrakt-first — real kod i 0pt-motor/motor/parsing/routing.py
|
||||
(route_parser m.fl.), INTEGRATION_TESTED men ej driftsatt bakom
|
||||
denna route.
|
||||
x-siax-status: target
|
||||
security: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RouteParsingRequest"
|
||||
responses:
|
||||
"200":
|
||||
description: Routingbeslut (parser/OCR-gren) + ev. nyckeltalskonflikter mellan parsers
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RouteParsingResponse"
|
||||
"400":
|
||||
$ref: "#/components/responses/BadRequest"
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
/v1/0pt/normalize:
|
||||
post:
|
||||
operationId: 0pt.normalize_value
|
||||
summary: >
|
||||
(TARGET) Lokal-medveten normalisering — belopp/skala/datum (BTI-NLP-03)
|
||||
och identifierare/checksummor (BTI-NLP-02). Kontrakt-first — real kod
|
||||
i 0pt-motor/motor/normalization/{amounts,identifiers}.py,
|
||||
INTEGRATION_TESTED men ej driftsatt bakom denna route.
|
||||
x-siax-status: target
|
||||
security: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/NormalizeValueRequest"
|
||||
responses:
|
||||
"200":
|
||||
description: Normaliserat värde — format_valid/review, aldrig en påhittad korrigering
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/NormalizeValueResponse"
|
||||
"400":
|
||||
$ref: "#/components/responses/BadRequest"
|
||||
"401":
|
||||
$ref: "#/components/responses/Unauthorized"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Internal service-to-service (Python-engine bridge) — P-002 internal OpenAPI.
|
||||
@@ -811,3 +865,91 @@ components:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: "#/components/schemas/FieldProvenance"
|
||||
RouteParsingRequest:
|
||||
type: object
|
||||
required: [digital_text_page]
|
||||
properties:
|
||||
digital_text_page:
|
||||
type: boolean
|
||||
description: True om sidan har ett digitalt textlager (ej scannad).
|
||||
ocr_available:
|
||||
type: boolean
|
||||
default: false
|
||||
parser_result:
|
||||
type: object
|
||||
description: Föregående parser-försök, om något (tom text = kandidat för OCR-gren).
|
||||
properties:
|
||||
parser:
|
||||
type: string
|
||||
text:
|
||||
type: string
|
||||
key_figures:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: number
|
||||
compare_with:
|
||||
type: object
|
||||
description: (Valfritt) ett andra parser-resultat att stämma av mot — avvikande nyckeltal blir en konflikt, aldrig en tyst ersättning.
|
||||
properties:
|
||||
parser:
|
||||
type: string
|
||||
text:
|
||||
type: string
|
||||
key_figures:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: number
|
||||
RouteParsingResponse:
|
||||
type: object
|
||||
required: [routing]
|
||||
properties:
|
||||
routing:
|
||||
type: string
|
||||
enum: [text_parser, ocr_branch, explicit_unavailable]
|
||||
conflicts:
|
||||
type: object
|
||||
description: Fält där de två parser-resultatens nyckeltal skiljer sig (present endast om compare_with skickades).
|
||||
additionalProperties: true
|
||||
NormalizeValueRequest:
|
||||
type: object
|
||||
required: [kind, value]
|
||||
properties:
|
||||
kind:
|
||||
type: string
|
||||
enum: [amount, percent, date, identifier]
|
||||
description: amount/percent/date = motor/normalization/amounts.py. identifier = motor/normalization/identifiers.py.
|
||||
value:
|
||||
type: string
|
||||
description: Rå textsträng att normalisera (belopp, procentsats, datum eller identifierare).
|
||||
locale:
|
||||
type: string
|
||||
description: (kind=amount, valfritt) comma_decimal|dot_decimal — auto-detekteras annars.
|
||||
unit:
|
||||
type: string
|
||||
description: (kind=amount|percent) t.ex. SEK/KSEK/MSEK/GSEK eller "%"/"pp".
|
||||
identifier_kind:
|
||||
type: string
|
||||
enum: [orgnr, cvr, vat, ocr]
|
||||
description: (kind=identifier, krävs) vilken identifierartyp som ska valideras.
|
||||
country:
|
||||
type: string
|
||||
description: (kind=identifier, krävs) ISO-3166 alpha-2, t.ex. SE/NO/DK.
|
||||
description: >
|
||||
Ett fält, en normalisering. amount/percent/date har alltid en explicit
|
||||
precision/skala (aldrig en påhittad dag eller sammanblandad enhet).
|
||||
identifier ger format_valid eller review — aldrig en tyst korrigerad
|
||||
checksumma; existens i register verifieras inte här.
|
||||
NormalizeValueResponse:
|
||||
type: object
|
||||
required: [kind, status]
|
||||
properties:
|
||||
kind:
|
||||
type: string
|
||||
enum: [amount, percent, date, identifier]
|
||||
status:
|
||||
type: string
|
||||
enum: [ok, format_valid, format_invalid, review, unparseable]
|
||||
result:
|
||||
type: object
|
||||
description: Normaliserat resultat, formen beror på kind (se motor/normalization/{amounts,identifiers}.py).
|
||||
additionalProperties: true
|
||||
|
||||
Reference in New Issue
Block a user