Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Semantic kernel OpenApi TestPlugin MessagesOpenAPI

From Leeroopedia
Knowledge Sources
Domains OpenAPI, Testing, Microsoft_Graph
Last Updated 2026-02-11 00:00 GMT

Overview

OpenAPI v3.0.1 YAML test specification describing a subset of the Microsoft Graph OData messages API, used as test fixture data in the Functions unit tests of the Semantic Kernel .NET SDK.

Description

This YAML file is an OpenAPI v3.0.1 specification that models a subset of the Microsoft Graph v1.0 messages API. Unlike the Azure Key Vault test documents, this specification tests more complex real-world API patterns including OData query parameters, paginated collections, component references ($ref), and rich schema definitions for email message objects.

Key features of this specification:

  • GET /me/messages - List messages in the signed-in user's mailbox with OData query parameters ($top, $skip, $search, $filter, $count, $orderby, $select, $expand)
  • POST /me/sendMail - Send a mail message with a request body reference
  • Component schemas - Full microsoft.graph.message schema with properties like categories, changeKey, body content, recipients, and attachments
  • Component parameters - Reusable parameter definitions referenced via $ref
  • Component request bodies and responses - Shared definitions for message collections and send mail payloads
  • Pagination support via x-ms-pageable extension

Usage

This file is loaded during unit test execution to validate the OpenAPI parser's handling of complex real-world API specifications with component references, OData query conventions, and rich nested schemas. It exercises the parser's ability to resolve $ref pointers, handle paginated response collections, and extract operations from Graph-style API definitions.

Code Reference

Source Location

Signature

openapi: 3.0.1
info:
  title: OData Service for namespace microsoft.graph - Subset
  description: This OData service is located at https://graph.microsoft.com/v1.0
  version: v1.0
servers:
  - url: https://graph.microsoft.com/v1.0
paths:
  /me/messages:
    get:
      tags:
        - me.message
      summary: Get the messages in the signed-in user's mailbox
      operationId: me_ListMessages
      parameters:
        - name: includeHiddenMessages
          in: query
          description: Include Hidden Messages
          schema:
            type: string
        - $ref: '#/components/parameters/top'
        - $ref: '#/components/parameters/skip'

Import

// Load the Messages OpenAPI document in unit tests
var stream = Assembly.GetExecutingAssembly()
    .GetManifestResourceStream("messages-openapi.yml");

// Or read directly from the TestPlugins directory
var yaml = File.ReadAllText("OpenApi/TestPlugins/messages-openapi.yml");

I/O Contract

Inputs

Name Type Required Description
includeHiddenMessages string (query) no Include hidden messages in the response
$top integer (query) no Limit the number of items returned (OData)
$skip integer (query) no Skip the first N items (OData)
$search string (query) no Search items by search phrases (OData)
$filter string (query) no Filter items by property values (OData)
$count boolean (query) no Include count of items (OData)
$orderby array of string (query) no Order items by property values
$select array of string (query) no Select properties to be returned
$expand array of string (query) no Expand related entities
sendMailRequestBody object (body) yes (POST) Mail message body for the sendMail action

Outputs

Name Type Description
messageCollectionResponse object Paginated collection of microsoft.graph.message objects with @odata.nextLink
microsoft.graph.message object Email message with id, categories, subject, body, sender, recipients, and attachments
204 (sendMail) empty Success response for the sendMail action

Usage Examples

Parsing the Messages OpenAPI Spec in a Unit Test

// Example: Loading and parsing the Messages OpenAPI YAML document
using var stream = File.OpenRead("OpenApi/TestPlugins/messages-openapi.yml");
var operations = await OpenApiDocumentParser.ParseAsync(stream);

// Verify the me_ListMessages operation was extracted
var listMessages = operations.First(op => op.Id == "me_ListMessages");
Assert.Equal("GET", listMessages.Method.ToString());
Assert.Equal("https://graph.microsoft.com/v1.0", listMessages.ServerUrl);

// Verify OData parameters are resolved from $ref
Assert.Contains(listMessages.Parameters, p => p.Name == "$top");
Assert.Contains(listMessages.Parameters, p => p.Name == "$filter");

// Verify sendMail operation
var sendMail = operations.First(op => op.Id == "me_sendMail");
Assert.Equal("POST", sendMail.Method.ToString());

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment