public string GetContainedItemTypeName(
            SwaggerResource swaggerResource,
            ResourceChildItem resourceChildItem)
        {
            var schemaPrefix = resourceChildItem.SchemaProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{resourceChildItem.Name}"));
        }
Ejemplo n.º 2
0
        public string GetReferenceName(ResourceClassBase swaggerResource, Reference reference)
        {
            var schemaPrefix = swaggerResource.Entity.DomainModel.SchemaNameMapProvider
                               .GetSchemaMapByPhysicalName(swaggerResource.Entity.Schema)
                               .ProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{reference.ReferenceTypeName}"));
        }
 public Schema GetEdFiEntityExtensionBridgeSchema(ResourceClassBase resource, ISwaggerResourceContext resourceContext)
 {
     return(resource.Extensions.Any(extension => _documentContext.IsIncludedExtension(extension.ObjectType))
         ? new Schema
     {
         @ref = SwaggerDocumentHelper.GetDefinitionReference(SwaggerDocumentHelper.GetEdFiExtensionBridgeName(resource, resourceContext))
     }
         : null);
 }
        public string GetResourceName(Resource resource, ISwaggerResourceContext resourceContext)
        {
            var schemaPrefix = resource
                               .Entity
                               .DomainModel
                               .SchemaNameMapProvider
                               .GetSchemaMapByPhysicalName(resource.Entity.Schema)
                               .ProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{resource.Name}"));
        }
Ejemplo n.º 5
0
        public TypeScriptGenerateTests(ITestOutputHelper outputHelper)
        {
            _outputHelper          = outputHelper;
            _nswagDocumentHelper   = new NSWagDocumentHelper();
            _swaggerDocumentHelper = new SwaggerDocumentHelper();
            var nSwagDocument = LoadSettings().Result;

            _openApiDocument         = LoadOpenApi().Result;
            _selfTypeScriptGenerator = new SelfTypeScriptGenerator(nSwagDocument.CodeGenerators
                                                                   .OpenApiToTypeScriptClientCommand.Settings, _openApiDocument);
        }
        public string GetResourceName(SwaggerResource swaggerResource, ContentTypeUsage contentTypeUsage)
        {
            var resource = swaggerResource.Resource;

            var schemaPrefix =
                resource.Entity.DomainModel.SchemaNameMapProvider.GetSchemaMapByPhysicalName(
                    resource.Entity.Schema)
                .ProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{resource.Name}"));
        }
Ejemplo n.º 7
0
        public string GetContainedItemTypeName(SwaggerResource swaggerResource, ResourceChildItem resourceChildItem)
        {
            var name = resourceChildItem.IsDerivedFrom(swaggerResource.Resource)
                ? CreateChildModelTypeName(
                swaggerResource.Resource,
                resourceChildItem.Name,
                resourceChildItem.Parent)
                : resourceChildItem.Name;

            return
                (SwaggerDocumentHelper.CamelCaseSegments(
                     $"{resourceChildItem.SchemaProperCaseName}_{name}_{swaggerResource.OperationNamingContext}"));
        }
Ejemplo n.º 8
0
        public string GetCollectionReferenceName(SwaggerResource swaggerResource, Collection collection)
        {
            var name = collection.IsDerivedFrom(swaggerResource.Resource)
                ? CreateChildModelTypeName(
                swaggerResource.Resource,
                collection.ItemType.Name,
                collection.Parent)
                : collection.ItemType.Name;

            return
                (SwaggerDocumentHelper.CamelCaseSegments(
                     $"{collection.ItemType.SchemaProperCaseName}_{name}_{swaggerResource.OperationNamingContext}"));
        }
        public string GetEmbeddedObjectReferenceName(
            SwaggerResource swaggerResource,
            EmbeddedObject embeddedObject)
        {
            var schemaPrefix = embeddedObject
                               .ObjectType
                               .Entity
                               .DomainModel
                               .SchemaNameMapProvider
                               .GetSchemaMapByPhysicalName(embeddedObject.ObjectType.Entity.Schema)
                               .ProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{embeddedObject.ObjectType.Name}"));
        }
        public string GetCollectionReferenceName(
            SwaggerResource swaggerResource,
            Collection collection)
        {
            var schemaPrefix = collection
                               .ItemType
                               .Entity
                               .DomainModel
                               .SchemaNameMapProvider
                               .GetSchemaMapByPhysicalName(collection.ItemType.Entity.Schema)
                               .ProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaPrefix}_{collection.ItemType.Name}"));
        }
Ejemplo n.º 11
0
        private IDictionary <string, Schema> CreateEdFiExtensionSchemas(ResourceClassBase resourceClassBase, ISwaggerResourceContext resourceContext)
        {
            var extensions = new Dictionary <string, Schema>();

            //Add the bridge extension object with all extension references.
            var bridgeSchema = _bridgeStrategy.GetEdFiExtensionBridgeSchema(resourceClassBase, resourceContext);

            if (bridgeSchema != null)
            {
                extensions.Add(
                    SwaggerDocumentHelper.GetEdFiExtensionBridgeName(resourceClassBase, resourceContext),
                    bridgeSchema);
            }

            return(extensions);
        }
Ejemplo n.º 12
0
        public string GetResourceName(Resource resource, ISwaggerResourceContext resourceContext)
        {
            var name = resourceContext.ContextualResource == null
                ? string.Format(
                @"{0}_{1}_{2}",
                resource.SchemaProperCaseName,
                CompositeTermInflector.MakeSingular(resource.Name),
                resourceContext.OperationNamingContext)
                       .ToCamelCase()
                : string.Format(
                @"{0}_{1}_{2}_{3}",
                resource.SchemaProperCaseName,
                CompositeTermInflector.MakeSingular(resource.Name),
                resourceContext.ContextualResource.Name,
                resourceContext.OperationNamingContext);

            return(SwaggerDocumentHelper.CamelCaseSegments(name));
        }
        private static string CreateCompositeChildModelTypeName(string resourceName, string childTypeName, ResourceClassBase containingResource)
        {
            if (containingResource is IHasParent)
            {
                return(SwaggerDocumentHelper.CamelCaseSegments(
                           string.Join(
                               "_",
                               ((IHasParent)containingResource)
                               .GetLineage()
                               .Select(x => x.Name.ToCamelCase())
                               .Concat(
                                   new[]
                {
                    childTypeName.ToCamelCase()
                }))));
            }

            return(SwaggerDocumentHelper.CamelCaseSegments($"{resourceName.ToCamelCase()}_{childTypeName.ToCamelCase()}"));
        }
 public Schema GetEdFiExtensionBridgeSchema(ResourceClassBase resourceClassBase, ISwaggerResourceContext resourceContext)
 {
     return(new Schema
     {
         type = "object", properties = resourceClassBase.ExtensionByName
                                       .Where(kvp => _documentContext.IsIncludedExtension(kvp.Value.ObjectType))
                                       .ToDictionary(
             pair => pair.Key,
             pair =>
             new Schema
         {
             @ref =
                 SwaggerDocumentHelper.GetDefinitionReference(
                     SwaggerDocumentHelper
                     .GetResourceExtensionDefinitionName(
                         pair.Value,
                         resourceContext))
         })
     });
 }
        public string GetResourceName(SwaggerResource swaggerResource, ContentTypeUsage contentTypeUsage)
        {
            var schemaPrefix =
                swaggerResource.Resource.Entity.DomainModel.SchemaNameMapProvider
                .GetSchemaMapByPhysicalName(swaggerResource.Resource.Entity.Schema)
                .ProperCaseName;

            var name = swaggerResource.ContextualResource == null
                ? string.Format(
                "{0}_{1}_{2}",
                schemaPrefix,
                CompositeTermInflector.MakeSingular(swaggerResource.Resource.Name),
                contentTypeUsage)
                : string.Format(
                "{0}_{1}_{2}_{3}",
                schemaPrefix,
                CompositeTermInflector.MakeSingular(swaggerResource.Resource.Name),
                swaggerResource.ContextualResource.Name,
                contentTypeUsage);

            return(SwaggerDocumentHelper.CamelCaseSegments(name));
        }
        public string GetReferenceName(ResourceClassBase resource, Reference reference)
        {
            var schemaProperCaseName = reference.ReferencedResource.SchemaProperCaseName;

            return(SwaggerDocumentHelper.CamelCaseSegments($"{schemaProperCaseName}_{reference.ReferenceTypeName}"));
        }
Ejemplo n.º 17
0
 public string GetEmbeddedObjectReferenceName(SwaggerResource swaggerResource, EmbeddedObject embeddedObject)
 {
     return
         (SwaggerDocumentHelper.CamelCaseSegments(
              $@"{embeddedObject.ObjectType.SchemaProperCaseName}_{embeddedObject.ObjectType.Name}_{swaggerResource.OperationNamingContext}"));
 }