Exemple #1
0
 private static string PropertyValueGenerator(OpenApiParameter parameter, IDictionary <string, OpenApiSchema> componentsSchemas, bool useForBadRequest, string?customValue)
 {
     // Match on OpenApiSchemaExtensions->GetDataType
     return(parameter.Schema.GetDataType() switch
     {
         "double" => ValueTypeTestPropertiesHelper.CreateValueDouble(),
         "long" => ValueTypeTestPropertiesHelper.Number(parameter.Name, useForBadRequest),
         "int" => ValueTypeTestPropertiesHelper.Number(parameter.Name, useForBadRequest),
         "bool" => ValueTypeTestPropertiesHelper.CreateValueBool(useForBadRequest),
         "string" => ValueTypeTestPropertiesHelper.CreateValueString(parameter.Name, parameter.Schema.Format, parameter.In, useForBadRequest, 0, customValue),
         "DateTimeOffset" => ValueTypeTestPropertiesHelper.CreateValueDateTimeOffset(useForBadRequest),
         "Guid" => ValueTypeTestPropertiesHelper.CreateValueGuid(useForBadRequest),
         "Uri" => ValueTypeTestPropertiesHelper.CreateValueUri(useForBadRequest),
         "Email" => ValueTypeTestPropertiesHelper.CreateValueEmail(useForBadRequest),
         _ => PropertyValueGeneratorTypeResolver(parameter, componentsSchemas, useForBadRequest)
     });
        private static string PropertyValueGenerator(KeyValuePair <string, OpenApiSchema> schema, IDictionary <string, OpenApiSchema> componentsSchemas, bool useForBadRequest, int itemNumber, string?customValue)
        {
            var name = schema.Key.EnsureFirstCharacterToUpper();

            // Match on OpenApiSchemaExtensions->GetDataType
            return(schema.Value.GetDataType() switch
            {
                "double" => ValueTypeTestPropertiesHelper.CreateValueDouble(),
                "long" => ValueTypeTestPropertiesHelper.Number(name, useForBadRequest),
                "int" => ValueTypeTestPropertiesHelper.Number(name, useForBadRequest),
                "bool" => ValueTypeTestPropertiesHelper.CreateValueBool(useForBadRequest),
                "string" => ValueTypeTestPropertiesHelper.CreateValueString(name, schema.Value.Format, null, useForBadRequest, itemNumber, customValue),
                "DateTimeOffset" => ValueTypeTestPropertiesHelper.CreateValueDateTimeOffset(useForBadRequest),
                "Guid" => ValueTypeTestPropertiesHelper.CreateValueGuid(useForBadRequest, itemNumber),
                "Uri" => ValueTypeTestPropertiesHelper.CreateValueUri(useForBadRequest),
                "Email" => ValueTypeTestPropertiesHelper.CreateValueEmail(useForBadRequest),
                _ => PropertyValueGeneratorTypeResolver(schema, componentsSchemas, useForBadRequest)
            });