Skip to content

Commit

Permalink
Merge pull request #2669 from metacosm/optimize-generation
Browse files Browse the repository at this point in the history
  • Loading branch information
fusesource-ci authored Dec 18, 2020
2 parents edc20a5 + 122e357 commit a018014
Show file tree
Hide file tree
Showing 58 changed files with 18,629 additions and 52,558 deletions.

Large diffs are not rendered by default.

673 changes: 84 additions & 589 deletions extensions/knative/model/src/main/resources/schema/knative-schema.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
"definitions": {
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshot": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshot",
"required": true
},
Expand All @@ -38,25 +35,20 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotClass": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"deletionPolicy": {
"type": "string",
"description": ""
"type": "string"
},
"driver": {
"type": "string",
"description": ""
"type": "string"
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshotClass",
"required": true
},
Expand All @@ -65,7 +57,6 @@
},
"parameters": {
"type": "object",
"description": "",
"existingJavaType": "java.util.Map\u003cString,String\u003e"
}
},
Expand All @@ -76,25 +67,21 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotClassList": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"items": {
"type": "array",
"description": "",
"items": {
"$ref": "#/definitions/github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotClass",
"existingJavaType": "io.fabric8.volumesnapshot.api.model.VolumeSnapshotClass"
}
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshotClassList",
"required": true
},
Expand All @@ -110,17 +97,14 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContent": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshotContent",
"required": true
},
Expand All @@ -143,25 +127,21 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContentList": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"items": {
"type": "array",
"description": "",
"items": {
"$ref": "#/definitions/github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContent",
"existingJavaType": "io.fabric8.volumesnapshot.api.model.VolumeSnapshotContent"
}
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshotContentList",
"required": true
},
Expand All @@ -177,16 +157,13 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContentSource": {
"type": "object",
"description": "",
"properties": {
"snapshotHandle": {
"type": "string",
"description": "",
"existingJavaType": "String"
},
"volumeHandle": {
"type": "string",
"description": "",
"existingJavaType": "String"
}
},
Expand All @@ -197,23 +174,19 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContentSpec": {
"type": "object",
"description": "",
"properties": {
"deletionPolicy": {
"type": "string",
"description": ""
"type": "string"
},
"driver": {
"type": "string",
"description": ""
"type": "string"
},
"source": {
"$ref": "#/definitions/github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContentSource",
"existingJavaType": "io.fabric8.volumesnapshot.api.model.VolumeSnapshotContentSource"
},
"volumeSnapshotClassName": {
"type": "string",
"description": "",
"existingJavaType": "String"
},
"volumeSnapshotRef": {
Expand All @@ -227,11 +200,9 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotContentStatus": {
"type": "object",
"description": "",
"properties": {
"creationTime": {
"type": "integer",
"description": "",
"existingJavaType": "Long"
},
"error": {
Expand All @@ -240,17 +211,14 @@
},
"readyToUse": {
"type": "boolean",
"description": "",
"existingJavaType": "Boolean"
},
"restoreSize": {
"type": "integer",
"description": "",
"existingJavaType": "Long"
},
"snapshotHandle": {
"type": "string",
"description": "",
"existingJavaType": "String"
}
},
Expand All @@ -261,11 +229,9 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotError": {
"type": "object",
"description": "",
"properties": {
"message": {
"type": "string",
"description": "",
"existingJavaType": "String"
},
"time": {
Expand All @@ -279,25 +245,21 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotList": {
"type": "object",
"description": "",
"properties": {
"apiVersion": {
"type": "string",
"description": "",
"default": "snapshot.storage.k8s.io/v1beta1",
"required": true
},
"items": {
"type": "array",
"description": "",
"items": {
"$ref": "#/definitions/github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshot",
"existingJavaType": "io.fabric8.volumesnapshot.api.model.VolumeSnapshot"
}
},
"kind": {
"type": "string",
"description": "",
"default": "VolumeSnapshotList",
"required": true
},
Expand All @@ -313,16 +275,13 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotSource": {
"type": "object",
"description": "",
"properties": {
"persistentVolumeClaimName": {
"type": "string",
"description": "",
"existingJavaType": "String"
},
"volumeSnapshotContentName": {
"type": "string",
"description": "",
"existingJavaType": "String"
}
},
Expand All @@ -333,15 +292,13 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotSpec": {
"type": "object",
"description": "",
"properties": {
"source": {
"$ref": "#/definitions/github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotSource",
"existingJavaType": "io.fabric8.volumesnapshot.api.model.VolumeSnapshotSource"
},
"volumeSnapshotClassName": {
"type": "string",
"description": "",
"existingJavaType": "String"
}
},
Expand All @@ -352,11 +309,9 @@
},
"github_com_kubernetes-csi_external-snapshotter_v2_pkg_apis_volumesnapshot_v1beta1_VolumeSnapshotStatus": {
"type": "object",
"description": "",
"properties": {
"boundVolumeSnapshotContentName": {
"type": "string",
"description": "",
"existingJavaType": "String"
},
"creationTime": {
Expand All @@ -368,7 +323,6 @@
},
"readyToUse": {
"type": "boolean",
"description": "",
"existingJavaType": "Boolean"
},
"restoreSize": {
Expand Down
19 changes: 11 additions & 8 deletions generator/pkg/schemagen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ type Constraint struct {
type CrdScope int32

const (
Namespaced CrdScope = 0
Cluster CrdScope = 1
BasePackage string = "io.fabric8.kubernetes.api.model"
Namespaced CrdScope = 0
Cluster CrdScope = 1
BasePackage string = "io.fabric8.kubernetes.api.model"
)

func GenerateSchema(schemaId string, crdLists map[reflect.Type]CrdScope, providedPackages map[string]string, manualTypeMap map[reflect.Type]string, packageMapping map[string]PackageInformation, mappingSchema map[string]string, providedTypes []ProvidedType, constraints map[reflect.Type]map[string]*Constraint) string {
Expand Down Expand Up @@ -289,11 +289,11 @@ func (g *schemaGenerator) generate(schemaId string, crdLists map[reflect.Type]Cr
}
javaType := g.javaType(k)
if strings.HasPrefix(javaType, "io.fabric8.") {
value.JavaTypeDescriptor = &JavaTypeDescriptor {
value.JavaTypeDescriptor = &JavaTypeDescriptor{
JavaType: javaType,
}
} else {
value.ExistingJavaTypeDescriptor = &ExistingJavaTypeDescriptor {
value.ExistingJavaTypeDescriptor = &ExistingJavaTypeDescriptor{
ExistingJavaType: javaType,
}
}
Expand Down Expand Up @@ -623,7 +623,10 @@ func (g *schemaGenerator) propertyDescriptorForSimpleField(field reflect.StructF
}

// add description
propertyDescriptor.Description = g.fieldDescription(field)
description := g.fieldDescription(field)
if len(description) > 0 {
propertyDescriptor.Description = description
}

return propertyDescriptor
}
Expand Down Expand Up @@ -663,8 +666,8 @@ func (g *schemaGenerator) propertyDescriptorForObject(field reflect.StructField)
g.handleType(fieldType)

return JSONPropertyDescriptor{
JSONReferenceDescriptor: g.referenceDescriptor(fieldType),
ExistingJavaTypeDescriptor: g.existingJavaTypeDescriptor(fieldType),
JSONReferenceDescriptor: g.referenceDescriptor(fieldType),
ExistingJavaTypeDescriptor: g.existingJavaTypeDescriptor(fieldType),
}
}

Expand Down
2 changes: 1 addition & 1 deletion generator/pkg/schemagen/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type JSONSchema struct {

type JSONDescriptor struct {
Type string `json:"type"`
Description string `json:"description"`
Description string `json:"description,omitempty"`
Default string `json:"default,omitempty"`
Required bool `json:"required,omitempty"`
Minimum float32 `json:"minimum,omitempty"`
Expand Down
Loading

0 comments on commit a018014

Please sign in to comment.