Module atelier_describe::graphml::writer[][src]

Expand description

Writes out a model in the GraphML representation form.

For more information see the GraphML specification, and primer.

Mapping

The outer graphml and graph elements are created as per the specification. For each shape in the model a GraphML node is created, with the following properties:

  1. The node’s ID is the fully qualified shape ID.
  2. The node will have a child data element, with key “type”, and a value that represents the shape type.
  3. IFF the shape is a service, the node will have a data value, with key “version”, and a value which is the service’s version string.

A set of edges are also created with the node ID from above as the source:

  1. For each trait applied to the shape the target of the edge is the trait’s shape ID and the edge has a child data element, with key “trait”, and the value true.
  2. For each member of an aggregate shape the target of the edge is the member’s target shape ID and the edge has a child data element, with key “member”, and a value from member, key, or value.
  3. For each member of a service shape the target of the edge is the member’s target shape ID and the edge has a child data element, with key “member”, where the value is the member name component of the member’s ID.

Example

For the message of the day model, this writer will generate the following XML.

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
        http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
    <key id="smithy-version" for="graph" attr.name="smithy.version" attr.type="string"/>
    <key id="type" for="node" attr.name="type" attr.type="string"/>
    <key id="version" for="node" attr.name="version" attr.type="string"/>
    <key id="trait" for="edge" attr.name="trait" attr.type="boolean"/>
    <key id="member" for="edge" attr.name="member" attr.type="string">
        <default>member</default>
    </key>
    <graph id="model" edgedefault="directed">
        <data key="smithy.version">1.0</data>
        <node id="example.motd#GetMessageOutput">
            <data key="type">structure</data>
        </node>
        <edge id="e0" source="example.motd#GetMessageOutput" target="smithy.api#String">
            <data key="member">message</data>
        </edge>
        <node id="example.motd#BadDateValue">
            <data key="type">structure</data>
        </node>
        <edge id="e1" source="example.motd#BadDateValue" target="smithy.api#error">
            <data key="trait">true</data>
        </edge>
        <edge id="e2" source="example.motd#BadDateValue" target="smithy.api#String">
            <data key="member">errorMessage</data>
        </edge>
        <node id="example.motd#Date">
            <data key="type">string</data>
        </node>
        <edge id="e3" source="example.motd#Date" target="smithy.api#pattern">
            <data key="trait">true</data>
        </edge>
        <node id="example.motd#MessageOfTheDay">
            <data key="type">service</data>
            <data key="version">2020-06-21</data>
        </node>
        <edge id="e4" source="example.motd#MessageOfTheDay" target="smithy.api#documentation">
            <data key="trait">true</data>
        </edge>
        <edge id="e5" source="example.motd#MessageOfTheDay" target="example.motd#Message">
            <data key="member">resources</data>
        </edge>
        <node id="example.motd#Message">
            <data key="type">resource</data>
        </node>
        <edge id="e6" source="example.motd#Message" target="example.motd#GetMessage">
            <data key="member">read</data>
        </edge>
        <node id="example.motd#GetMessage">
            <data key="type">operation</data>
        </node>
        <edge id="e7" source="example.motd#GetMessage" target="smithy.api#readonly">
            <data key="trait">true</data>
        </edge>
        <edge id="e8" source="example.motd#GetMessage" target="example.motd#GetMessageInput">
            <data key="member">input</data>
        </edge>
        <edge id="e9" source="example.motd#GetMessage" target="example.motd#GetMessageInput">
            <data key="member">output</data>
        </edge>
        <edge id="e10" source="example.motd#GetMessage" target="example.motd#BadDateValue">
            <data key="member">errors</data>
        </edge>
        <node id="example.motd#GetMessageInput">
            <data key="type">structure</data>
        </node>
        <edge id="e11" source="example.motd#GetMessageInput" target="example.motd#Date">
            <data key="member">date</data>
        </edge>
    </graph>
</graphml>

Structs

GraphMLWriter

Writes out a model in the GraphML XML form.