Skip to content

Commit 5092481

Browse files
authored
Update OpenAPI spec (#160)
## Changes Update of the OpenAPI spec. This also introduces the template_libraries field being added in databricks/databricks-sdk-go#635. This PR contains some other changes: 1. Change `float`/`Float` to `double`/`Double`. OpenAPI specs currently specify `format: "double"` for all non-integral numeric values. 2. Remove old types that were previously in the OpenAPI spec but are no longer needed. 3. Do not generate files for types that don't correspond to distinct Java types (e.g. are not objects or enums). A lot of extra files are generated unnecessarily today, corresponding to either integers/strings/booleans or arrays/maps. Since Java has no type-def functionality, these are represented in the SDK as their JDK equivalents. ## Tests Added AccountMetastoreAssignmentsIT to verify the correct functionality of the updated AccountMetastoreAssignments API. Nightly tests passed on this PR.
1 parent 02faddc commit 5092481

File tree

185 files changed

+3347
-1187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+3347
-1187
lines changed

.codegen.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"formatter": "mvn spotless:apply",
3+
"template_libraries": [
4+
".codegen/lib.tmpl"
5+
],
36
"types": {
47
".codegen/model.java.tmpl": "databricks-sdk-java/src/main/java/com/databricks/sdk/service/{{.Package.Name}}/{{.PascalName}}.java"
58
},
@@ -19,6 +22,7 @@
1922
},
2023
"toolchain": {
2124
"require": ["mvn", "java"],
25+
"setup": ["rm -r databricks-sdk-java/src/main/java/com/databricks/sdk/service"],
2226
"post_generate": ["mvn --errors clean test"]
2327
}
2428
}

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
09a7fa63d9ae243e5407941f200960ca14d48b07
1+
bcbf6e851e3d82fd910940910dd31c10c059746c

.codegen/api.java.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public class {{.PascalName}}API {
9999
{{range .Methods}}
100100
{{if and .Request .Request.RequiredFields}}
101101
public {{template "method-return-type" .}} {{template "java-name" .}}({{range $i, $p := .Request.RequiredFields -}}
102-
{{if $i}}, {{end}}{{template "type" .Entity }} {{.CamelName}}{{if .IsNameReserved}}Value{{end}}
102+
{{if $i}}, {{end}}{{template "type-unboxed" .Entity }} {{.CamelName}}{{if .IsNameReserved}}Value{{end}}
103103
{{- end}}) {
104104
{{if or .Response .Wait -}}return {{end}}{{template "java-name" .}}(new {{.Request.PascalName}}(){{range .Request.RequiredFields}}
105105
.set{{.PascalName}}({{.CamelName}}{{if .IsNameReserved}}Value{{end}}){{end}});
@@ -173,9 +173,9 @@ public class {{.PascalName}}API {
173173
{{define "method-return-type" -}}
174174
{{if and .Wait (and (not .IsCrudRead) (not (eq .SnakeName "get_run"))) }}Wait<{{.Wait.Poll.Response.PascalName}},{{if .Response}}{{.Response.PascalName}}{{else}}Void{{end}}>
175175
{{- else if .Response}}{{if .Response.ArrayValue -}}
176-
Iterable<{{.Response.ArrayValue.PascalName}}>
176+
Iterable<{{ template "type" .Response.ArrayValue }}>
177177
{{- else if .Pagination -}}
178-
Iterable<{{.Pagination.Entity.PascalName}}>
178+
Iterable<{{ template "type" .Pagination.Entity }}>
179179
{{- else -}}
180180
{{template "type" .Response}}
181181
{{- end}}{{else}}void{{end}}

.codegen/interface.java.tmpl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,3 @@ public interface {{.PascalName}}Service {
2323
{{if .Response -}}{{template "type" .Response}}{{else}}void{{end}} {{.CamelName}}{{if .IsNameReserved}}Content{{end}}({{if .Request}}{{template "type" .Request}} {{.Request.CamelName}}{{if .IsNameReserved}}Content{{end}}{{end}});
2424
{{end}}
2525
}
26-
{{- define "type" -}}
27-
{{- if not . }}Object /* ERROR */
28-
{{- else if .IsEmpty}}Object
29-
{{- else if .IsAny}}Object
30-
{{- else if .IsString}}String
31-
{{- else if .IsBool}}boolean
32-
{{- else if .IsInt64}}long
33-
{{- else if .IsFloat64}}float
34-
{{- else if .IsInt}}long
35-
{{- else if .ArrayValue }}Collection<{{template "type" .ArrayValue}}>
36-
{{- else if .MapValue }}Map<String,{{template "type" .MapValue}}>
37-
{{- else if .IsByteStream}}InputStream
38-
{{- else if .IsObject }}{{.PascalName}}
39-
{{- else if .IsExternal }}com.databricks.sdk.service.{{.Package.Name}}.{{.PascalName}}
40-
{{- else if .Enum }}{{.PascalName}}
41-
{{- else}}Object /* MISSING TYPE */
42-
{{- end -}}
43-
{{- end -}}

.codegen/lib.tmpl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- define "type-unboxed" -}}
2+
{{- if .IsBool}}boolean
3+
{{- else if .IsInt64}}long
4+
{{- else if .IsFloat64}}double
5+
{{- else if .IsInt}}long
6+
{{- else }}{{template "type" .}}{{end}}
7+
{{- end -}}
8+
9+
{{- define "type" -}}
10+
{{- if not . }}Object /* ERROR */
11+
{{- else if .IsEmpty}}Object
12+
{{- else if .IsAny}}Object
13+
{{- else if .IsString}}String
14+
{{- else if .IsBool}}Boolean
15+
{{- else if .IsInt64}}Long
16+
{{- else if .IsFloat64}}Double
17+
{{- else if .IsInt}}Long
18+
{{- else if .ArrayValue }}Collection<{{template "type" .ArrayValue}}>
19+
{{- else if .MapValue }}Map<String,{{template "type" .MapValue}}>
20+
{{- else if .IsByteStream}}InputStream
21+
{{- else if .IsObject }}{{.PascalName}}
22+
{{- else if .IsExternal }}com.databricks.sdk.service.{{.Package.Name}}.{{.PascalName}}
23+
{{- else if .Enum }}{{.PascalName}}
24+
{{- else}}Object /* MISSING TYPE */
25+
{{- end -}}
26+
{{- end -}}

.codegen/model.java.tmpl

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public class {{.PascalName}} {
6565
{{- end}}.toString();
6666
}
6767
}
68-
{{else if .ArrayValue}}// type {{.PascalName}} []{{template "type" .ArrayValue}}
69-
{{else if .MapValue}}// type {{.PascalName}} {{template "type" .}}
7068
{{else if .Enum -}}
7169
@Generated
7270
public enum {{.PascalName}}{
@@ -75,23 +73,9 @@ public enum {{.PascalName}}{
7573
@JsonProperty("{{.Content}}") {{end}}{{.ConstantName}},{{.Comment "// " 80}}
7674
{{ end }}
7775
}
76+
{{ else }}
77+
Any types that have no fields (i.e. primitives or array types) or are not enums are not represented by distinct Java
78+
types in the Java SDK.
79+
{{skipThisFile}}
7880
{{- end}}
7981

80-
{{- define "type" -}}
81-
{{- if not . }}Object /* ERROR */
82-
{{- else if .IsEmpty}}Object
83-
{{- else if .IsAny}}Object
84-
{{- else if .IsString}}String
85-
{{- else if .IsBool}}Boolean
86-
{{- else if .IsInt64}}Long
87-
{{- else if .IsFloat64}}Float
88-
{{- else if .IsInt}}Long
89-
{{- else if .ArrayValue }}Collection<{{template "type" .ArrayValue}}>
90-
{{- else if .MapValue }}Map<String,{{template "type" .MapValue}}>
91-
{{- else if .IsByteStream}}InputStream
92-
{{- else if .IsObject }}{{.PascalName}}
93-
{{- else if .IsExternal }}com.databricks.sdk.service.{{.Package.Name}}.{{.PascalName}}
94-
{{- else if .Enum }}{{.PascalName}}
95-
{{- else}}Object /* MISSING TYPE */
96-
{{- end -}}
97-
{{- end -}}

0 commit comments

Comments
 (0)