@@ -11,14 +11,68 @@ class DownloadSpecsPlugin implements Plugin<Project> {
1111 @Override
1212 void apply (Project project ) {
1313 project. tasks. register(" downloadApiSpec" ) {
14- println (' Downloading spec' )
15- File file = new File (" ${ project.buildDir} /openapi.yml" )
16- if (! file. getParentFile(). exists())
17- file. getParentFile(). mkdirs();
18- if (! file. exists())
19- file. createNewFile();
20- file. withOutputStream { out ->
21- new URL (specUrl). withInputStream { from -> out << from }
14+ doLast {
15+ println (' Downloading spec' )
16+ File file = new File (" ${ project.buildDir} /openapi.yml" )
17+ if (! file. getParentFile(). exists())
18+ file. getParentFile(). mkdirs();
19+ if (! file. exists())
20+ file. createNewFile();
21+ file. withOutputStream { out ->
22+ new URL (specUrl). withInputStream { from -> out << from }
23+ }
24+
25+ // Patch the OpenAPI spec to fix SynonymItemSchema allOf issue
26+ // The swagger code generator doesn't handle allOf correctly, so we convert it
27+ // to a direct definition that includes all fields
28+ println (' Patching OpenAPI spec for SynonymItemSchema' )
29+ String content = file. text
30+
31+ // Find and replace the allOf structure with a direct definition
32+ String allOfBlock = ''' SynonymItemSchema:
33+ allOf:
34+ - type: object
35+ required:
36+ - id
37+ properties:
38+ id:
39+ type: string
40+ description: Unique identifier for the synonym item
41+ - $ref: "#/components/schemas/SynonymItemUpsertSchema"'''
42+
43+ String replacement = ''' SynonymItemSchema:
44+ type: object
45+ required:
46+ - id
47+ - synonyms
48+ properties:
49+ id:
50+ type: string
51+ description: Unique identifier for the synonym item
52+ synonyms:
53+ type: array
54+ description: Array of words that should be considered as synonyms
55+ items:
56+ type: string
57+ root:
58+ type: string
59+ description: For 1-way synonyms, indicates the root word that words in the synonyms parameter map to
60+ locale:
61+ type: string
62+ description: Locale for the synonym, leave blank to use the standard tokenizer
63+ symbols_to_index:
64+ type: array
65+ description: By default, special characters are dropped from synonyms. Use this attribute to specify which special characters should be indexed as is
66+ items:
67+ type: string'''
68+
69+ if (content. contains(allOfBlock)) {
70+ content = content. replace(allOfBlock, replacement)
71+ file. text = content
72+ println (' Successfully patched SynonymItemSchema' )
73+ } else {
74+ println (' Warning: SynonymItemSchema allOf block not found, skipping patch' )
75+ }
2276 }
2377 }
2478 }
0 commit comments