private static V1beta1JSONSchemaProps Convert(this V1JSONSchemaProps props) { var betaProps = new V1beta1JSONSchemaProps(); betaProps.Nullable = props.Nullable; betaProps.Description = props.Description; if (props.ExternalDocs != null) { betaProps.ExternalDocs = new V1beta1ExternalDocumentation( props.ExternalDocs.Description, props.ExternalDocs.Url); } betaProps.MaxItems = props.MaxItems; betaProps.MinItems = props.MinItems; betaProps.UniqueItems = props.UniqueItems; betaProps.MaxLength = props.MaxLength; betaProps.MinLength = props.MinLength; betaProps.MultipleOf = props.MultipleOf; betaProps.Pattern = props.Pattern; betaProps.Maximum = props.Maximum; betaProps.ExclusiveMaximum = props.ExclusiveMaximum; betaProps.Minimum = props.Minimum; betaProps.ExclusiveMinimum = props.ExclusiveMinimum; if (props.Properties != null) { betaProps.Properties = new Dictionary <string, V1beta1JSONSchemaProps>( props.Properties.Select(p => KeyValuePair.Create(p.Key, p.Value.Convert()))); } betaProps.Type = props.Type; betaProps.Format = props.Format; betaProps.Items = (props.Items as V1JSONSchemaProps)?.Convert(); betaProps.Required = props.Required; betaProps.EnumProperty = props.EnumProperty; return(betaProps); }
private V1beta1JSONSchemaProps MapSchemaToKubernetesModels(JsonSchema schema) { var result = new V1beta1JSONSchemaProps(); result.Type = (schema.Type & ~JsonSchemaType.Null).ToString().ToLower(); result.Pattern = schema.Pattern; if (schema.Properties != null) { result.Properties = new Dictionary <string, V1beta1JSONSchemaProps>(); foreach (var property in schema.Properties) { result.Properties.Add(property.Key, MapSchemaToKubernetesModels(property.Value)); } } if (schema.Items != null) { result.Items = schema.Items.Select(item => MapSchemaToKubernetesModels(item)); } return(result); }