Skip to content

Commit c558316

Browse files
authored
Merge pull request #3 from Equal-IQ/contract-variables
Add ContractVariable structure and ContractVariableType enum
2 parents 1c020dd + 72edf15 commit c558316

File tree

6 files changed

+106
-3
lines changed

6 files changed

+106
-3
lines changed

Containers/Containerfile-python-codegen

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ COPY api.json /app/api.json
1212
RUN datamodel-codegen --input api.json --input-file-type openapi --output /app/models.py \
1313
--output-model-type pydantic_v2.BaseModel \
1414
--target-python-version 3.11 \
15-
--field-constraints
15+
--field-constraints \
16+
--disable-timestamp
1617

1718
CMD ["cat", "/app/models.py"]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ https://smithy.io/2.0/index.html
1010

1111
## 🚀 Quickstart: Generate OpenAPI + Type Definitions
1212

13+
Modify the model in ./smithy then run
14+
15+
```bash
16+
./build-openapi.sh && ./build-types.sh --all
17+
```
18+
19+
1320
### 📦 Prerequisites
1421

1522
Only **Docker** is required for containerized builds. No need to install Java, Gradle, Python, or Node.js locally.

model/equaliq.smithy

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ service EqualIQ {
3535

3636
// When changing APIs, we sometimes want to expose unified types that aren't directly tied to any API.
3737
structure ExposedTypes {
38-
QASectionsList: QASectionsList
38+
QASectionsList: QASectionsList // This type is not properly included in API response currently
39+
ContractVariable: ContractVariable // New feature in development by Ty
40+
ContractVariableType: ContractVariableType // New feature in development by Ty
3941
}
4042

4143
// This API is used simply to expose types
@@ -102,6 +104,13 @@ enum SignContractResult {
102104
FAILURE
103105
}
104106

107+
enum ContractVariableType {
108+
EQ_TERM = "eq_term"
109+
DISCOVERED_TERM = "discovered_term"
110+
EXTERNAL_TERM = "external_term"
111+
INTERNAL_CITATION = "internal_citation"
112+
}
113+
105114
// Contract operations
106115
@http(method: "POST", uri: "/getContract")
107116
operation GetContract {
@@ -628,6 +637,41 @@ structure FixedTermValue {
628637
condition: String
629638
}
630639

640+
// Contract variable structures
641+
642+
structure ContractVariable {
643+
@required
644+
name: String
645+
646+
@required
647+
type: ContractVariableType
648+
649+
@required
650+
id: String
651+
652+
// the definition/explanation for this variable
653+
value: String
654+
655+
// 1-10 difficulty level (external terms only)
656+
level: Integer
657+
658+
confidence: Float
659+
660+
// character position
661+
firstOccurrence: Integer
662+
663+
// surrounding text
664+
context: String
665+
666+
// alternative forms
667+
variations: StringList
668+
669+
// for internal citations
670+
referencedSection: String
671+
672+
// where the term is defined (e.g., "Section 7(ii)(c)(I)") - for EQ_TERM and DISCOVERED_TERM only
673+
definitionCitation: String
674+
}
631675

632676
// Common structures
633677
document Document

python/api_model/types/models.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# generated by datamodel-codegen:
22
# filename: api.json
3-
# timestamp: 2025-07-03T19:26:05+00:00
43

54
from __future__ import annotations
65

@@ -47,6 +46,13 @@ class ContractType(Enum):
4746
tbd = 'tbd'
4847

4948

49+
class ContractVariableType(Enum):
50+
eq_term = 'eq_term'
51+
discovered_term = 'discovered_term'
52+
external_term = 'external_term'
53+
internal_citation = 'internal_citation'
54+
55+
5056
class DeleteContractRequestContent(BaseModel):
5157
contractId: str = Field(..., pattern='^[A-Za-z0-9-]+$')
5258

@@ -259,13 +265,33 @@ class ContractSummaryItem(BaseModel):
259265
sharedEmails: Optional[List[str]] = None
260266

261267

268+
class ContractVariable(BaseModel):
269+
name: str
270+
type: ContractVariableType
271+
id: str
272+
value: Optional[str] = None
273+
level: Optional[float] = None
274+
confidence: Optional[float] = None
275+
firstOccurrence: Optional[float] = None
276+
context: Optional[str] = None
277+
variations: Optional[List[str]] = None
278+
referencedSection: Optional[str] = None
279+
definitionCitation: Optional[str] = None
280+
281+
262282
class DeleteContractSignatureResponseContent(BaseModel):
263283
result: Optional[SignContractResult] = None
264284
message: Optional[str] = None
265285

266286

267287
class ExposeTypesResponseContent(BaseModel):
268288
QASectionsList: Optional[List[QASection]] = None
289+
ContractVariable_1: Optional[ContractVariable] = Field(
290+
None, alias='ContractVariable'
291+
)
292+
ContractVariableType_1: Optional[ContractVariableType] = Field(
293+
None, alias='ContractVariableType'
294+
)
269295

270296

271297
class GetContractResponseContent(BaseModel):

typescript/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type ExtractSchema<K extends SchemaNames> = components['schemas'][K];
1414
export type AuthenticationErrorResponseContent = ExtractSchema<'AuthenticationErrorResponseContent'>
1515
export type ContractSignature = ExtractSchema<'ContractSignature'>
1616
export type ContractSummaryItem = ExtractSchema<'ContractSummaryItem'>
17+
export type ContractVariable = ExtractSchema<'ContractVariable'>
1718
export type DeleteContractRequestContent = ExtractSchema<'DeleteContractRequestContent'>
1819
export type DeleteContractResponseContent = ExtractSchema<'DeleteContractResponseContent'>
1920
export type DeleteContractSignatureRequestContent = ExtractSchema<'DeleteContractSignatureRequestContent'>

typescript/src/models.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,22 @@ export interface components {
340340
};
341341
/** @enum {string} */
342342
ContractType: ContractType;
343+
ContractVariable: {
344+
name: string;
345+
type: components["schemas"]["ContractVariableType"];
346+
id: string;
347+
value?: string;
348+
level?: number;
349+
/** Format: float */
350+
confidence?: number;
351+
firstOccurrence?: number;
352+
context?: string;
353+
variations?: string[];
354+
referencedSection?: string;
355+
definitionCitation?: string;
356+
};
357+
/** @enum {string} */
358+
ContractVariableType: ContractVariableType;
343359
DeleteContractRequestContent: {
344360
contractId: string;
345361
};
@@ -355,6 +371,8 @@ export interface components {
355371
};
356372
ExposeTypesResponseContent: {
357373
QASectionsList?: components["schemas"]["QASection"][];
374+
ContractVariable?: components["schemas"]["ContractVariable"];
375+
ContractVariableType?: components["schemas"]["ContractVariableType"];
358376
};
359377
FixedTermValue: {
360378
unit: string;
@@ -1323,6 +1341,12 @@ export enum ContractType {
13231341
services = "services",
13241342
tbd = "tbd"
13251343
}
1344+
export enum ContractVariableType {
1345+
eq_term = "eq_term",
1346+
discovered_term = "discovered_term",
1347+
external_term = "external_term",
1348+
internal_citation = "internal_citation"
1349+
}
13261350
export enum SignContractResult {
13271351
SUCCESS = "SUCCESS",
13281352
FAILURE = "FAILURE"

0 commit comments

Comments
 (0)