Adding Patterned Objects to OpenApi output

I’m currently working on improving our OpenApi specs and using some 3rd party documentation generators. I’m trying to find a way to add Pattered Objects to operations and the root definition.

Specifically I want to be able to add some x-something vendor tags within my documentation.

For example, I want to be able to add the following to an operation

"x-code-samples":[{
     "lang": "JavaScript",
  "source": "console.log('Hello World');"
}]

and something like the following to the root object

"x-tagGroups": [
		{
			"name": "Usage",
			"tags" :["Pagination"]
		},
		{
		  "name": "User Management",
		  "tags": ["company", "search"]
		},
		{
		  "name": "Statistics",
		  "tags": ["orders", "proposals"]
		}
	  ]

I’ve been playing around with Operation and ApiDeclaration Filters, but not able to figure out how to add new schemas.

For operation you can extend OpenApiOperation and use derived class instead of OpenApiOperation

    [DataContract]
    public class CodeSample
    {
        [DataMember(Name = "lang")]
        public string Language { get; set; }

        [DataMember(Name = "source")]
        public string Source { get; set;  }
    }

    [DataContract]
    public class ExtendedOperation : OpenApiOperation
    {
        [DataMember(Name = "x-code-samples")]
        public List<CodeSample> CodeSamples { get; set; }
    }

And configure method

public override void Configure(Container container)
{
    JsConfig<ExtendedOperation>.ExcludeTypeInfo = true;

    Plugins.Add(new OpenApiFeature {
        ApiDeclarationFilter = (api) =>
        {
            var path = api.Paths["/hello"];

            path.Post = new ExtendedOperation
            {
                CodeSamples = new List<CodeSample>
                {
                    new CodeSample {Language = "javacript", Source = "console.log('Hello World');"}
                }
            }.PopulateWith(path.Post);
        }
    });
}

About root object where do you want to add this code? Can you provide a full json sample?

thanks. I’ll give that a try. Here’s a sample of what I’m looking to do with the other. Specifically I’m using ReDoc to generate documentation and want to keep additional doc modifications part of code rather than separate edits all the time.

{
	"swagger": "2.0",
	"info": {
		"title": "API",
		"version": "2.0",
		"x-logo" :{
			"url":"",
			"backgroundColor":"#fafafa"
		},
		"description" : ""    	
	},
	"x-tagGroups": [
		{
			"name": "Authentication",
			"tags" :["General","JWT Authentication","authenticate"]
		},
		{
		  "name": "Company",
		  "tags": ["company", "suppliers", "settings", "rewards", "itemsettings", "Credit Cards", "Company"]
		},
		{
		  "name": "User",
		  "tags": ["users"]
		},
		{
		  "name": "Location",
		  "tags": ["location"]
		},
		{
		  "name": "Orders",
		  "tags": ["orders"]
		},
		{
		  "name": "Proposal",
		  "tags": ["proposal"]
		},
		{
		  "name": "Search",
		  "tags": ["search", "Category", "initialsearch", "products", "Search", "public"]
		}
	],
	  
	"x-servers": [
		{
		  "url": "https://dev/api",
		  "description": "Development server"
		},
		{
		  "url": "https://staging/api",
		  "description": "Staging server"
		},
		{
		  "url": "https://prod/api",
		  "description": "Production server"
		}
	],