internal OpenApiConvertSettings Clone()
        {
            var newSettings = new OpenApiConvertSettings
            {
                ServiceRoot                                     = this.ServiceRoot,
                Version                                         = this.Version,
                EnableKeyAsSegment                              = this.EnableKeyAsSegment,
                EnableUnqualifiedCall                           = this.EnableUnqualifiedCall,
                EnableOperationPath                             = this.EnableOperationPath,
                EnableOperationImportPath                       = this.EnableOperationImportPath,
                EnableNavigationPropertyPath                    = this.EnableNavigationPropertyPath,
                TagDepth                                        = this.TagDepth,
                PrefixEntityTypeNameBeforeKey                   = this.PrefixEntityTypeNameBeforeKey,
                OpenApiSpecVersion                              = this.OpenApiSpecVersion,
                EnableOperationId                               = this.EnableOperationId,
                VerifyEdmModel                                  = this.VerifyEdmModel,
                IEEE754Compatible                               = this.IEEE754Compatible,
                TopExample                                      = this.TopExample,
                EnableUriEscapeFunctionCall                     = this.EnableUriEscapeFunctionCall,
                EnablePagination                                = this.EnablePagination,
                PageableOperationName                           = this.PageableOperationName,
                EnableDiscriminatorValue                        = this.EnableDiscriminatorValue,
                EnableDerivedTypesReferencesForResponses        = this.EnableDerivedTypesReferencesForResponses,
                EnableDerivedTypesReferencesForRequestBody      = this.EnableDerivedTypesReferencesForRequestBody,
                RoutePathPrefixProvider                         = this.RoutePathPrefixProvider,
                ShowLinks                                       = this.ShowLinks,
                RequireDerivedTypesConstraintForBoundOperations = this.RequireDerivedTypesConstraintForBoundOperations,
                ShowSchemaExamples                              = this.ShowSchemaExamples,
                ShowRootPath                                    = this.ShowRootPath,
                PathProvider                                    = this.PathProvider
            };

            return(newSettings);
        }
Exemple #2
0
        /// <summary>
        /// Convert <see cref="IEdmModel"/> to <see cref="OpenApiDocument"/> using a convert settings.
        /// </summary>
        /// <param name="model">The Edm model.</param>
        /// <param name="settings">The convert settings.</param>
        /// <returns>The converted Open API document object, <see cref="OpenApiDocument"/>.</returns>
        public static OpenApiDocument ConvertToOpenApi(this IEdmModel model, OpenApiConvertSettings settings)
        {
            Utils.CheckArgumentNull(model, nameof(model));
            Utils.CheckArgumentNull(settings, nameof(settings));

            if (settings.VerifyEdmModel)
            {
                IEnumerable <EdmError> errors;
                if (!model.Validate(out errors))
                {
                    OpenApiDocument document = new OpenApiDocument();
                    int             index    = 1;
                    foreach (var error in errors)
                    {
                        document.Extensions.Add(Constants.xMsEdmModelError + index++, new OpenApiString(error.ToString()));
                    }

                    return(document);
                }
            }

            ODataContext context = new ODataContext(model, settings);

            return(context.CreateDocument());
        }
        internal OpenApiConvertSettings Clone()
        {
            var newSettings = new OpenApiConvertSettings();

            newSettings.ServiceRoot                   = this.ServiceRoot;
            newSettings.Version                       = this.Version;
            newSettings.EnableKeyAsSegment            = this.EnableKeyAsSegment;
            newSettings.EnableUnqualifiedCall         = this.EnableUnqualifiedCall;
            newSettings.EnableOperationPath           = this.EnableOperationPath;
            newSettings.EnableOperationImportPath     = this.EnableOperationImportPath;
            newSettings.EnableNavigationPropertyPath  = this.EnableNavigationPropertyPath;
            newSettings.TagDepth                      = this.TagDepth;
            newSettings.PrefixEntityTypeNameBeforeKey = this.PrefixEntityTypeNameBeforeKey;
            newSettings.EnableOperationId             = this.EnableOperationId;
            newSettings.VerifyEdmModel                = this.VerifyEdmModel;
            newSettings.IEEE754Compatible             = this.IEEE754Compatible;

            return(newSettings);
        }