Skip to content

Comma separated tags are shown different in the metadata page or API Explorer #788

@digiofficerobin

Description

@digiofficerobin

Describe the issue

Create a request with tags, such as this:

[Tag("Tag1,Tag2")]
[Route("/projects", "GET")]
public class GetProjects : IReturn<List<Project>>
{
	public string SearchCriteria { get; set; }
}

[Tag("Tag2,Tag3")]
[Route("/projects", "GET")]
public class GetProjectsV2 : IReturn<List<Project>>
{
	public string SearchCriteria { get; set; }
}

public class Project
{
	public int ID { get; set; }
	public Guid GlobalID { get; set; }
	public string Number { get; set; }
	public string Name { get; set; }
	public string Description1 { get; set; }
	public string Description2 { get; set; }
	public string Description { get; set; }
	public string City { get; set; }
	public bool Active { get; set; }
}

We can conveniently filter all requests in the metadata page with tag1, tag2 or tag3, but not in API Explorer or Swagger.

TaggingInServiceStack

We want to use this tagging feature to decorate APIs which are available since a certain release. I have made a ReleaseTagAttribute to automatically determine the in-between releases.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class ReleaseTagAttribute : TagAttribute
{
	public ReleaseTagAttribute() : this(null) { }
	public ReleaseTagAttribute(string since) => Name = getInnerReleaseTags(since, "2023.2");
	public ReleaseTagAttribute(string since, string until) => Name = getInnerReleaseTags(since, until);

	private string getInnerReleaseTags(string since, string until)
	{
		var sinceMajor = int.Parse(since.Split('.')[0]);
		var sinceMinor = int.Parse(since.Split('.')[1]);
		var untilMajor = int.Parse(until.Split('.')[0]);
		var untilMinor = int.Parse(until.Split('.')[1]);

		if (sinceMajor == untilMajor && sinceMinor == untilMinor)
		{
			return sinceMajor + "." + sinceMinor;
		}
		else
		{
			var nextMajor = sinceMajor;
			var nextMinor = sinceMinor;

			if (sinceMinor == 2)
			{
				nextMajor++;
				nextMinor = 1;
			}
			else
			{
				nextMinor++;
			}

			return sinceMajor + "." + sinceMinor + "," + getInnerReleaseTags(nextMajor + "." + nextMinor, until);
		}
	}
}

Example in metadata page with release number decoration on the two GetProjects requests:
image

In API Explorer the commas are not separated as different groups:
image

In Swagger UI the tags are also not seen as unique tags:
image

Can this issue be solved one way or the other?

Reproduction

see issue description

Expected behavior

see issue description

System Info

ServiceStack 6.4.0

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions