protected override OpenApiSchema GenerateDefinitionSchema(ApiModel apiModel, SchemaRepository schemaRepository) { var apiObject = (ApiObject)apiModel; var additionalProperties = (apiObject.AdditionalPropertiesType != null) ? Generator.GenerateSchema(apiObject.AdditionalPropertiesType, schemaRepository) : null; var schema = new OpenApiSchema { Type = "object", Properties = new Dictionary <string, OpenApiSchema>(), Required = new SortedSet <string>(), AdditionalPropertiesAllowed = (additionalProperties != null), AdditionalProperties = additionalProperties }; foreach (var apiProperty in apiObject.ApiProperties) { // For data annotations, support inline attributes (i.e. applied to member directly) OR attributes applied through a MetadataType var propertyAttributes = (apiProperty.MemberInfo is PropertyInfo propertyInfo) ? propertyInfo.GetInlineOrMetadataTypeAttributes() : Enumerable.Empty <object>(); if (Options.IgnoreObsoleteProperties && propertyAttributes.OfType <ObsoleteAttribute>().Any()) { continue; } schema.Properties.Add(apiProperty.ApiName, GeneratePropertySchema(apiProperty, propertyAttributes, schemaRepository)); if (apiProperty.ApiRequired || propertyAttributes.OfType <RequiredAttribute>().Any()) { schema.Required.Add(apiProperty.ApiName); } } return(schema); }
protected override OpenApiSchema GenerateDefinitionSchema(ApiModel apiModel, SchemaRepository schemaRepository) { return(new OpenApiSchema { Type = "string" }); }
protected override bool CanGenerateSchema(ApiModel apiModel, out bool shouldBeReferenced) { shouldBeReferenced = false; return(true); }
protected abstract OpenApiSchema GenerateDefinitionSchema(ApiModel apiModel, SchemaRepository schemaRepository);
protected abstract bool CanGenerateSchema(ApiModel apiModel, out bool shouldBeReferenced);