public static SwaggerGenOptions ConfigureForNetTopologySuite(this SwaggerGenOptions c) { c.DocumentFilter <DocumentFilter>(); c.MapType <Geometry>( () => new OpenApiSchema { ExternalDocs = new OpenApiExternalDocs { Url = new Uri("http://geojson.org/geojson-spec.html#geometry-objects"), }, Type = "object", Extensions = new Dictionary <string, IOpenApiExtension> { ["clrType"] = new OpenApiString(typeof(Geometry).FullName) }, Description = "GeoJSon geometry", Discriminator = new OpenApiDiscriminator { PropertyName = "type", }, Required = new HashSet <string> { "type" }, Properties = new Dictionary <string, OpenApiSchema> {
public void Traverse(OpenApiExternalDocs docs) { if (docs == null) { return; } Visitor.Visit(docs); }
/// <summary> /// Visits <see cref="OpenApiExternalDocs"/> and child objects /// </summary> internal void Walk(OpenApiExternalDocs externalDocs) { if (externalDocs == null) { return; } _visitor.Visit(externalDocs); }
public static OpenApiExternalDocs LoadExternalDocs(ParseNode node) { var mapNode = node.CheckMapNode("externalDocs"); var externalDocs = new OpenApiExternalDocs(); ParseMap(mapNode, externalDocs, _externalDocsFixedFields, _externalDocsPatternFields); return(externalDocs); }
private OAExternalDocs CreateExternalDocs(OpenApiExternalDocs ExternalDocs) { if (ExternalDocs != null) { return(new OAExternalDocs() { Description = ExternalDocs.Description, Url = ExternalDocs.Url.ToString(), }); } return(new OAExternalDocs()); }
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) { var tags = new List <OpenApiTag> { new() { Name = "Companies", Description = "Companies related interface", ExternalDocs = new OpenApiExternalDocs { Description = "Read more", Url = new Uri("https://github.com/matjazbravc") } }, new() { Name = "Departments", Description = "Departments related interface", ExternalDocs = new OpenApiExternalDocs { Description = "Here are some Departments public interfaces" } }, new() { Name = "Employees", Description = "Employees related interface", ExternalDocs = new OpenApiExternalDocs { Description = "Here are some Employees public interfaces" } } , new() { Name = "Users", Description = "Users related interface", ExternalDocs = new OpenApiExternalDocs { Description = "Here are some Users public interfaces" } } }; // Sort in ascending order by AssemblyName swaggerDoc.Tags = tags.OrderBy(x => x.Name).ToList(); } }
public void ValidateUrlIsRequiredInExternalDocs() { // Arrange OpenApiExternalDocs externalDocs = new OpenApiExternalDocs(); // Act var errors = externalDocs.Validate(ValidationRuleSet.GetDefaultRuleSet()); // Assert bool result = !errors.Any(); Assert.False(result); Assert.NotNull(errors); OpenApiError error = Assert.Single(errors); Assert.Equal(String.Format(SRResource.Validation_FieldIsRequired, "url", "External Documentation"), error.Message); }
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) { var tags = new List <OpenApiTag> { new() { Name = "ExchangeRatesCoinCap", Description = "Exchangerates API", ExternalDocs = new OpenApiExternalDocs { Description = "Read more", Url = new Uri(DOCS_URI) } } }; // Sort in ascending order by AssemblyName swaggerDoc.Tags = tags.OrderBy(x => x.Name).ToList(); } }
/// <summary> /// Visits <see cref="OpenApiComponents"/> /// </summary> public virtual void Visit(OpenApiExternalDocs externalDocs) { }
/// <summary> /// Visits <see cref="OpenApiExternalDocs"/> and child objects /// </summary> /// <param name="externalDocs"></param> internal void Walk(OpenApiExternalDocs externalDocs) { _visitor.Visit(externalDocs); }
/// <summary> /// Execute validation rules against an <see cref="OpenApiExternalDocs"/> /// </summary> /// <param name="item">The object to be validated</param> public override void Visit(OpenApiExternalDocs item) => Validate(item);
public override void Visit(OpenApiExternalDocs externalDocs) { Locations.Add(this.PathString); }
/// <summary> /// Returns the <see cref="OpenApiPathItem" /> for the Authorize Endpoint /// </summary> public virtual OpenApiPathItem AuthorizeEndpointPathItem() { var queryParameters = new List <OpenApiParameter>() { new OpenApiParameter() { In = ParameterLocation.Query, Name = "client_id", Required = true, Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "identifier of the client", AllowEmptyValue = false, }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "request", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "instead of providing all parameters as individual query string parameters, you can provide a subset or all of them as a JWT", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "request_uri", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "URL of a pre-packaged JWT containing request parameters", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "scope", Required = true, Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "one or more registered scopes", AllowEmptyValue = false, }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "redirect_uri", Required = true, Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "must exactly match one of the allowed redirect URIs for that client", AllowEmptyValue = false, }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "response_type", Required = true, Schema = new OpenApiSchema() { Type = DataTypes.String, Enum = new List <IOpenApiAny> { new OpenApiString("id_token"), new OpenApiString("token"), new OpenApiString("id_token token"), new OpenApiString("code"), new OpenApiString("code id_token"), new OpenApiString("code id_token token") } }, Description = "the response type: code, ideneity token and/or access token", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "response_mode", Required = false, Schema = new OpenApiSchema() { Type = DataTypes.String, Enum = new List <IOpenApiAny> { new OpenApiString("form_post"), } }, Description = "sends the token response as a form post instead of a fragment encoded redirect", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "state", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "identityserver will echo back the state value on the token response, this is for round tripping state between client and provider, correlating request and response and CSRF/replay protection. (recommended)", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "nonce", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "identityserver will echo back the nonce value in the identity token, this is for replay protection. Required for identity tokens via implicit grant", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "prompt", Required = false, Schema = new OpenApiSchema() { Type = DataTypes.String, Enum = new List <IOpenApiAny> { new OpenApiString("none"), new OpenApiString("login"), } }, Description = "the login UI will be shown or not", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "code_challenge", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "sends the code challenge for PKCE", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "code_challenge_method", Required = false, Schema = new OpenApiSchema() { Type = DataTypes.String, Enum = new List <IOpenApiAny> { new OpenApiString("plain"), new OpenApiString("S256"), } }, Description = "plain indicates that the challenge is using plain text (not recommended) S256 indicates the challenge is hashed with SHA256", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "login_hint", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "can be used to pre-fill the username field on the login page", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "ui_locales", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "gives a hint about the desired display language of the login UI", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "max_age", Schema = new OpenApiSchema() { Type = DataTypes.String, }, Description = "if the user’s logon session exceeds the max age (in seconds), the login UI will be shown", }, new OpenApiParameter() { In = ParameterLocation.Query, Name = "acr_values", Required = false, Schema = new OpenApiSchema() { Type = DataTypes.Array, Enum = new List <IOpenApiAny> { new OpenApiString("idp:name_of_idp"), new OpenApiString("tenant:name_of_tenant "), }, }, Description = "allows passing in additional authentication related information - identityserver special cases the following proprietary acr_values:", }, }; var body = new OpenApiMediaType() { Schema = new OpenApiSchema() { Properties = queryParameters.ToDictionary(k => k.Name, v => new OpenApiSchema() { Type = v.Schema.Type, Description = v.Description, Enum = v.Schema.Enum, }), Required = queryParameters.Where(x => x.Required).Select(x => x.Name).ToHashSet() } }; var responseExernalDoc = new OpenApiExternalDocs() { Description = "Authorize Endpoint", Url = new System.Uri("http://docs.identityserver.io/en/latest/endpoints/authorize.html") }; var responseDescription = "Request tokens or authorization codes via the browser"; return(new OpenApiPathItem { Description = "The authorize endpoint can be used to request tokens or authorization codes via the browser. This process typically involves authentication of the end-user and optionally consent.", Operations = new Dictionary <OperationType, OpenApiOperation> { [OperationType.Get] = new OpenApiOperation { Description = responseDescription, ExternalDocs = responseExernalDoc, Parameters = queryParameters, Responses = new OpenApiResponses { ["302"] = new OpenApiResponse { Description = "OK", } } }, [OperationType.Post] = new OpenApiOperation { Description = responseDescription, ExternalDocs = responseExernalDoc, RequestBody = new OpenApiRequestBody() { Content = { ["application/x-www-form-urlencoded"] = body, ["multipart/form-data"] = body, }, }, Responses = new OpenApiResponses { ["200"] = new OpenApiResponse { Description = "OK", Content = new Dictionary <string, OpenApiMediaType>() { ["application/json"] = new OpenApiMediaType() { Schema = new OpenApiSchema() { Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "AuthorizeResponse" } } }, }, } } } } }); }
public override void Visit(OpenApiExternalDocs externalDocs) { EncodeCall(); base.Visit(externalDocs); }