API Reference JSON

An api section turns a JSON description of a public C# API into browsable pages for namespaces, types, and members. Generate the file with CSharpApiExtractor or create the same structure in another tool, then load it into the API Reference section editor.

Top-level structure

The root object is keyed by namespace. Each namespace value is an object keyed by the relative type name. Use an empty string as the namespace key for types in the global namespace. Nested type names use dot notation, for example Client.Options.

{
  "Acme.Sdk": {
    "Client": {
      "name": "Client",
      "summary": "Calls the Acme service.",
      "declaration": "public sealed class Client",
      "type": 0,
      "access": "public",
      "isStatic": 0,
      "isAbstract": 0,
      "baseClass": "Object",
      "interfaces": ["IDisposable"],
      "members": []
    }
  }
}

The namespace and type objects are required. Invalid namespace or type values are skipped. A type should have a non-empty key or name; declaration is used to build its stable viewer route.

Type fields

  • name — type name relative to the namespace. If omitted, the object key is used.
  • summary — documentation text, normally extracted from the XML summary.
  • declaration — complete C# declaration displayed in the reference.
  • type — type kind: 0 class, 1 interface, 2 struct, 3 enum, or 4 record. The strings class, interface, struct, enum, and record are also accepted. The default is class.
  • access — access modifier; the default is public.
  • isStatic, isAbstract — boolean-like flags. JSON booleans and 0/1 are accepted.
  • baseClass — base class name.
  • interfaces — array of implemented interface names.
  • members — array of member objects.

Member fields

Every member requires a non-empty name and a numeric type greater than zero. Unsupported or incomplete members are skipped.

  • type1 field or event, 2 property, 3 constructor, method, or operator, 4 delegate, 5 indexer, 6 enum value. A type-1 member whose valueType is Action, Func, or Predicate is shown as an event.
  • name, declaration, summary, and access describe the member and its displayed signature.
  • valueType contains the field, event, property, indexer, or return type.
  • isStatic, isVirtual, isAbstract, isGeneric, hasGet, and hasSet are boolean-like flags.
  • parameters is an array of parameter objects.

For type: 3, the name .ctor creates a constructor. A static name beginning with op_ creates an operator; other values create methods.

Member example

The following object describes a public asynchronous method. Place it inside the type's members array.

{
  "name": "GetAsync",
  "declaration": "public Task<Item> GetAsync(string id, CancellationToken cancellationToken = default)",
  "type": 3,
  "summary": "Gets an item by ID.",
  "access": "public",
  "isStatic": false,
  "isGeneric": false,
  "isVirtual": false,
  "isAbstract": false,
  "valueType": "Task<Item>",
  "parameters": [
    {
      "name": "id",
      "type": "string",
      "summary": "Item identifier."
    },
    {
      "name": "cancellationToken",
      "type": "CancellationToken",
      "summary": "Cancels the operation.",
      "isOptional": true,
      "defaultValue": "default"
    }
  ]
}

Parameter fields

  • name and type identify the parameter.
  • summary contains its documentation.
  • refKind stores modifiers such as ref, out, or in.
  • isOptional marks an optional parameter; defaultValue stores the displayed default value.

Complete example

{
  "Acme.Sdk": {
    "Client": {
      "name": "Client",
      "summary": "Calls the Acme service.",
      "declaration": "public sealed class Client : IDisposable",
      "type": 0,
      "baseClass": "Object",
      "interfaces": ["IDisposable"],
      "members": [
        {
          "name": ".ctor",
          "declaration": "public Client(string endpoint)",
          "type": 3,
          "summary": "Creates a client.",
          "parameters": [
            {
              "name": "endpoint",
              "type": "string",
              "summary": "Service URL."
            }
          ]
        },
        {
          "name": "GetAsync",
          "declaration": "public Task<Item> GetAsync(string id, CancellationToken cancellationToken = default)",
          "type": 3,
          "summary": "Gets an item.",
          "valueType": "Task<Item>",
          "parameters": [
            { "name": "id", "type": "string", "summary": "Item identifier." },
            {
              "name": "cancellationToken",
              "type": "CancellationToken",
              "isOptional": 1,
              "defaultValue": "default"
            }
          ]
        }
      ]
    }
  }
}

Validation and routes

The input must be valid JSON with an object at the root. One File Docs normalizes and sorts namespaces, types, and member groups. Viewer IDs are generated from declarations, so keep declarations stable and make overloaded member declarations distinct. After loading the file, review the namespace, type, and member counts shown by the editor before saving or exporting.