Exemple #1
0
        private void AddServiceDto(List <IServiceMemberInfo> members, string name, SwaggerSchema schema, SwaggerService swaggerService, NamedTextPosition position)
        {
            var attributes = new List <ServiceAttributeInfo>();

            if (schema.Obsolete.GetValueOrDefault())
            {
                attributes.Add(new ServiceAttributeInfo("obsolete"));
            }

            var fields = new List <ServiceFieldInfo>();

            foreach (var property in schema.Properties.EmptyIfNull())
            {
                var fieldAttributes = new List <ServiceAttributeInfo>();

                if (property.Value.Obsolete.GetValueOrDefault())
                {
                    fieldAttributes.Add(new ServiceAttributeInfo("obsolete"));
                }

                string typeName = swaggerService.TryGetFacilityTypeName(property.Value, position);
                if (typeName != null)
                {
                    fields.Add(new ServiceFieldInfo(
                                   property.Key,
                                   typeName: typeName,
                                   attributes: fieldAttributes,
                                   summary: PrepareSummary(property.Value.Description),
                                   position: position));
                }
            }

            members.Add(new ServiceDtoInfo(
                            name: name,
                            fields: fields,
                            attributes: attributes,
                            summary: PrepareSummary(schema.Description),
                            remarks: SplitRemarks(schema.Remarks),
                            position: position));
        }
Exemple #2
0
        private static SwaggerSchema GetDtoSchema(ServiceInfo serviceInfo, ServiceDtoInfo dtoInfo)
        {
            var propertiesObject = new OurDictionary <string, SwaggerSchema>();

            foreach (var fieldInfo in dtoInfo.Fields)
            {
                SwaggerSchema propertyObject = GetTypeSchema <SwaggerSchema>(serviceInfo.GetFieldType(fieldInfo));
                if (propertyObject.Ref == null)
                {
                    propertyObject.Description = GetSummaryOrNull(fieldInfo);
                    propertyObject.Obsolete    = GetObsoleteOrNull(fieldInfo);
                }
                propertiesObject[fieldInfo.Name] = propertyObject;
            }

            return(new SwaggerSchema
            {
                Type = SwaggerSchemaType.Object,
                Description = GetSummaryOrNull(dtoInfo),
                Properties = propertiesObject,
                Obsolete = GetObsoleteOrNull(dtoInfo),
                Remarks = GetRemarksOrNull(dtoInfo),
            });
        }
Exemple #3
0
        internal static KeyValuePair <string, SwaggerSchema> ResolveDefinition(this SwaggerService swaggerService, SwaggerSchema swaggerDefinition, NamedTextPosition position)
        {
            string name = null;

            if (swaggerDefinition.Ref != null)
            {
                name = GetDefinitionNameFromRef(swaggerDefinition.Ref, position);
                if (!swaggerService.Definitions.TryGetValue(name, out swaggerDefinition))
                {
                    throw new ServiceDefinitionException($"Missing definition named '{name}'.", position);
                }
            }

            return(new KeyValuePair <string, SwaggerSchema>(name, swaggerDefinition));
        }