Ejemplo n.º 1
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <Role>(with =>
     {
         with.Description("A role within the system");
     }));
 }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <ApiResponse <string> >(with =>
     {
         with.Description("An API response containing a string");
     }));
 }
 /// <summary>
 /// Gets the model data for the api documentation.
 /// </summary>
 /// <returns></returns>
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <RequestedModel>(
                with =>
     {
         with.Property(x => x.Title).Description("The requests title e.g. Star Wars Episode III").Required(true);
         with.Property(x => x.AdminNote).Description("A note left by the administrator");
         with.Property(x => x.Approved).Description("true or false if the request is approved").Required(true).Default(false);
         with.Property(x => x.ArtistId).Description("The artist ID (if this request is for Headphones then it is required)");
         with.Property(x => x.ArtistName).Description("The artist name (if this request is for Headphones then it is required)");
         with.Property(x => x.Available).Description("If the request is available on Plex").Default(false);
         with.Property(x => x.CanApprove).Description("Ignore");
         with.Property(x => x.ImdbId).Description("The IMDB id of the request").Required(true);
         with.Property(x => x.Issues)
         .Description(
             "The issue type,  None = 99, WrongAudio = 0, NoSubtitles = 1, WrongContent = 2, PlaybackIssues = 3, Other = 4. Use Other(4) when leaving an issue note");
         with.Property(x => x.MusicBrainzId).Description("The MusicBrainz ID of the album request (if this request is for Headphones then it is required)");
         with.Property(x => x.OtherMessage)
         .Description("The issue message left by the user. The Issues property needs to be set to Other (4) for this to work correctly");
         with.Property(x => x.PosterPath).Description("The poster path for the request").Required(true);
         with.Property(x => x.ProviderId)
         .Description("The TVMaze/TheMovieDB Id for the request depending if it's a movie request or Tv request")
         .Required(true);
         with.Property(x => x.ReleaseDate).Description("The release date of the request").Required(true);
         with.Property(x => x.RequestedDate)
         .Description("The date if the request, if this is not set, the request date will be set at the time of the Api call");
         with.Property(x => x.RequestedUsers).Description("A collection of the requested users").Required(true);
         with.Property(x => x.Type).Description("The type of request: Movie = 0, TvShow = 1, Album = 2").Required(true);
         with.Property(x => x.Id).Description("The request Id (Only use for deleting)");
     }));
 }
Ejemplo n.º 4
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <T>(with =>
     {
         with.Description(string.Empty);
     }));
 }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <ApiResponse <ApiResponse <string> > >(with =>
     {
         with.Description("An oddly double nested API response object");
     }));
 }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <AutoCompleteResponse>(builder =>
     {
         builder.Description("Response");
         builder.Property(r => r.MethodHeader).Default(null); //?
     }));
 }
Ejemplo n.º 7
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <QuickFix>(builder =>
     {
         builder.Property(p => p.LogLevel).Enum("Warning", "Error");
         builder.Property(p => p.EndLine).Default(-1);
         builder.Property(p => p.EndColumn).Default(-1);
     }));
 }
        private SwaggerModelData AnnotateSwaggerModelData(SwaggerModelData originalModel)
        {
            var type = originalModel.ModelType;

            var modelAttr = type.GetTypeInfo().GetCustomAttribute<ModelAttribute>();

            //If the type is not annotated, use the default model.
            return modelAttr == null ? originalModel : new AnnotatedModel(originalModel.ModelType, modelAttr);
        }
        private SwaggerModelData AnnotateSwaggerModelData(SwaggerModelData originalModel)
        {
            var type = originalModel.ModelType;

            var modelAttr = type.GetTypeInfo().GetCustomAttribute <ModelAttribute>();

            //If the type is not annotated, use the default model.
            return(modelAttr == null ? originalModel : new AnnotatedModel(originalModel.ModelType, modelAttr));
        }
Ejemplo n.º 10
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <Address>(with =>
     {
         with.Description("An address of a user");
         with.Property(x => x.Address1)
         .Description("First Line of Address")
         .Required(true);
     }));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the model data for the api documentation.
        /// </summary>
        /// <returns></returns>
        public SwaggerModelData GetModelData()
        {
            return(SwaggerModelData.ForType <UserUpdateViewModel>(
                       with =>
            {
                with.Property(x => x.CurrentPassword).Description("The users current password").Required(true);

                with.Property(x => x.NewPassword).Description("The users new password that we will change it to").Required(true);
            }));
        }
Ejemplo n.º 12
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <GotoDefinitionResponse>(builder =>
     {
         builder.Description("Response");
         builder.Property(p => p.Line).Minimum(1);
         builder.Property(p => p.Column).Minimum(1);
         builder.Property(p => p.FileName);
     }));
 }
Ejemplo n.º 13
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <Request>(builder =>
     {
         builder.Property(p => p.Buffer).Required(true);
         builder.Property(p => p.FileName).Required(true);
         builder.Property(p => p.Line).Required(true);
         builder.Property(p => p.Column).Required(true);
     }));
 }
Ejemplo n.º 14
0
 public SwaggerModelData GetModelData()
 => SwaggerModelData.ForType <SmsLoginRequest>(with =>
 {
     with.Description("Login request");
     with.Property(x => x.Phone)
     .Description("user phone like 71231234567")
     .Required(true);
     with.Property(x => x.Password)
     .Description("user password")
     .Required(true);
 });
Ejemplo n.º 15
0
        public SwaggerModelData GetModelData()
        {
            return(SwaggerModelData.ForType <T>(with => {
                System.Attribute[] attrs = System.Attribute.GetCustomAttributes(this.GetType());
                foreach (System.Attribute attr in attrs)
                {
                    if (attr is ModelDoc)
                    {
                        ModelDoc attr_doc = (ModelDoc)attr;
                        with.Description(attr_doc.Description);
                        var member_info = this.GetType().GetProperties();

                        List <Tuple <PropertyDoc, string> > prop_doc_list = new List <Tuple <PropertyDoc, string> >();
                        for (int i = 0; i < member_info.Length; i++)
                        {
                            PropertyDoc attr_prop = (PropertyDoc)System.Attribute.GetCustomAttribute(member_info[i], typeof(PropertyDoc));
                            if (attr_prop != null && attr_prop is PropertyDoc)
                            {
                                var tup = new Tuple <PropertyDoc, string>(attr_prop, member_info[i].Name);
                                prop_doc_list.Add(tup);
                            }
                        }

                        // put PropertyDoc in order
                        List <Tuple <PropertyDoc, string> > ordered_list = prop_doc_list.OrderBy(p => p.Item1.Index).ToList();
                        foreach (Tuple <PropertyDoc, string> attr_prop_tup in ordered_list)
                        {
                            PropertyDoc attr_prop = attr_prop_tup.Item1;
                            string attr_prop_name = attr_prop_tup.Item2;

                            var propertyData = with.Data.Properties.First(d => d.Name == attr_prop_name);
                            var swaggerData = new SwaggerModelPropertyDataBuilder <Object>(propertyData);
                            swaggerData.Description(attr_prop.Description);
                            if (attr_prop.RequiredHasValue)
                            {
                                swaggerData.Required(attr_prop.Required);
                            }
                            if (attr_prop.MinimumHasValue)
                            {
                                swaggerData.Minimum(attr_prop.Minimum);
                            }
                            if (attr_prop.MaximumHasValue)
                            {
                                swaggerData.Maximum(attr_prop.Maximum);
                            }
                            if (attr_prop.EnumValuesHasValue)
                            {
                                swaggerData.Enum(attr_prop.EnumValues);
                            }
                        }
                    }
                }
            }));
        }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <GotoDefinitionRequest>(builder =>
     {
         builder.Description("request");
         builder.Property(p => p.Buffer).Required(true);
         builder.Property(p => p.FileName).Required(true);
         builder.Property(p => p.Line).Minimum(1).Required(true);
         builder.Property(p => p.Column).Minimum(1).Required(true);
     }));
 }
Ejemplo n.º 17
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <AutoCompleteRequest>(builder =>
     {
         builder.Property(r => r.WordToComplete).Required(true);
         builder.Property(r => r.WantDocumentationForEveryCompletionResult).Description("Specifies whether to return the code documentation for each and every returned autocomplete result.");
         builder.Property(r => r.WantImportableTypes).Description("Specifies whether to return importable types. Defaults to false. Can be turned off to get a small speed boost.");
         builder.Property(r => r.WantMethodHeader).Description("Returns a 'method header' for working with parameter templating.");
         builder.Property(r => r.WantSnippet).Description("Returns a snippet that can be used by common snippet libraries to provide parameter and type parameter placeholders");
         builder.Property(r => r.WantReturnType).Description("Returns the return type ");
     }));
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Gets the model data for the api documentation.
        /// </summary>
        /// <returns></returns>
        public SwaggerModelData GetModelData()
        {
            return(SwaggerModelData.ForType <PlexSettings>(
                       with =>
            {
                with.Property(x => x.Ip).Description("The IP address of the Plex Server").Required(true);
                with.Property(x => x.Port).Description("The Port address of the Plex Server").Required(true).Default(32400);
                with.Property(x => x.Ssl).Description("Enable SSL").Required(false).Default(false);
                with.Property(x => x.FullUri).Description("Internal Property").Required(false);

                with.Property(x => x.SubDir).Description("Subdir/BaseUrl of Plex").Required(false);
            }));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Gets the model data for the api documentation.
 /// </summary>
 /// <returns></returns>
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <HeadphonesSettings>(
                with =>
     {
         with.Property(x => x.Ip).Description("The IP address of Headphones").Required(true);
         with.Property(x => x.Port).Description("The Port address of Headphones").Required(true).Default(5050);
         with.Property(x => x.Ssl).Description("Enable SSL").Required(false).Default(false);
         with.Property(x => x.FullUri).Description("Internal Property, do not use").Required(false).Default(null);
         with.Property(x => x.SubDir).Description("Subdir/BaseUrl of Headphones").Required(false);
         with.Property(x => x.ApiKey).Description("Headphones's API key").Required(true);
     }));
 }
Ejemplo n.º 20
0
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <User>(with =>
     {
         with.Description("A user of our awesome system!");
         with.Property(x => x.Name)
         .Description("The user's name")
         .Required(true);
         with.Property(x => x.Age)
         .Description("The user's age")
         .Required(true)
         .Minimum(1)
         .Maximum(100);
     }));
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets the model data for the api documentation.
        /// </summary>
        /// <returns></returns>
        public SwaggerModelData GetModelData()
        {
            return(SwaggerModelData.ForType <SickRageSettings>(
                       with =>
            {
                with.Property(x => x.Ip).Description("The IP address of SickRage").Required(true);
                with.Property(x => x.Port).Description("The Port address of SickRage").Required(true).Default(5050);
                with.Property(x => x.Ssl).Description("Enable SSL").Required(false).Default(false);
                with.Property(x => x.FullUri).Description("Internal Property").Required(false);

                with.Property(x => x.SubDir).Description("Subdir/BaseUrl of SickRage").Required(false);
                with.Property(x => x.ApiKey).Description("SickRage's API key").Required(true);
                with.Property(x => x.QualityProfile).Description("SickRage's quality profile").Required(false);
            }));
        }
 private Model CreateModel(SwaggerModelData model)
 {
     return new Model
     {
         Id = model.ModelType.DefaultModelId(),
         Description = model.Description,
         Required = model.Properties
                         .Where(p => p.Required || p.Type.IsImplicitlyRequired())
                         .Select(p => p.Name)
                         .OrderBy(name => name)
                         .ToList(),
         Properties = model.Properties
                           .OrderBy(p => p.Name)
                           .ToDictionary(p => p.Name, p => CreateModelProperty(p))
         // TODO: SubTypes and Discriminator
     };
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Gets the model data for the api documentation.
        /// </summary>
        /// <returns></returns>
        public SwaggerModelData GetModelData()
        {
            return(SwaggerModelData.ForType <SonarrSettings>(
                       with =>
            {
                with.Property(x => x.Ip).Description("The IP address of Sonarr").Required(true);
                with.Property(x => x.Port).Description("The Port address of Sonarr").Required(true).Default(5050);
                with.Property(x => x.Ssl).Description("Enable SSL").Required(false).Default(false);
                with.Property(x => x.FullUri).Description("Internal Property").Required(false);

                with.Property(x => x.SubDir).Description("Subdir/BaseUrl of Sonarr").Required(false);
                with.Property(x => x.ApiKey).Description("Sonarr's API key").Required(true);
                with.Property(x => x.QualityProfile).Description("Sonarr's quality profile").Required(true);

                with.Property(x => x.SeasonFolders).Description("Sonarr's season folders").Required(false);

                with.Property(x => x.RootPath).Description("Sonarr's root path").Required(false);
            }));
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Gets the model data for the api documentation.
 /// </summary>
 /// <returns></returns>
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <AuthenticationSettings>(
                with =>
     {
         with.Property(x => x.DeniedUserList)
         .Description("The blacklisted users, this is for internal use by the application, do not modify this list.")
         .Required(false);
         with.Property(x => x.DeniedUsers).Description("The blacklisted users, comma separated.").Required(false);
         with.Property(x => x.UsePassword)
         .Description("Require users to use a password to login when authentication is enabled")
         .Required(false)
         .Default(false);
         with.Property(x => x.UserAuthentication)
         .Description("Require users to enter their username in, this will check against Plex")
         .Required(false)
         .Default(false);
     }));
 }
        private SwaggerModelData CreateSwaggerModelData(Type type)
        {
            // Only use properties which have a pulbic getter and setter
            var typeProperties = type.GetProperties()
                                        .Where(pi => pi.CanWrite && pi.GetSetMethod(true).IsPublic)
                                        .Where(pi => pi.CanRead && pi.GetGetMethod(true).IsPublic);

            var modelData = new SwaggerModelData(type)
            {
                Properties = typeProperties.Select(CreateSwaggerModelPropertyData).ToList()
            };

            var modelAttr = type.GetCustomAttribute<ModelAttribute>();
            if (modelAttr != null)
            {
                modelData.Description = modelAttr.Description;
            }

            return modelData;
        }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <SendEmail>(
                with =>
     {
         with.Description("Команда отправки почты");
         with.Property(x => x.Id)
         .Description("Не используется")
         .Required(false);
         with.Property(x => x.To)
         .Description("Адрес назначения")
         .Required(true);
         with.Property(x => x.Subject)
         .Description("Тема письма")
         .Required(false);
         with.Property(x => x.HtmlBody)
         .Description("Тело письма в HTML-разметке")
         .Required(false);
     }));
 }
Ejemplo n.º 27
0
        private SwaggerModelData CreateSwaggerModelData(Type type)
        {
            // Only use properties which have a pulbic getter and setter
            var typeProperties = type.GetProperties()
                                 .Where(pi => pi.CanWrite && pi.GetSetMethod(true).IsPublic)
                                 .Where(pi => pi.CanRead && pi.GetGetMethod(true).IsPublic);

            var modelData = new SwaggerModelData(type)
            {
                Properties = typeProperties.Select(CreateSwaggerModelPropertyData).ToList()
            };

            var modelAttr = type.GetCustomAttribute <ModelAttribute>();

            if (modelAttr != null)
            {
                modelData.Description = modelAttr.Description;
            }

            return(modelData);
        }
 public SwaggerModelData GetModelData()
 {
     return(SwaggerModelData.ForType <QuickFixResponse>(builder => builder
                                                        .Property(p => p.QuickFixes).Description("A list of quick fixes")));
 }