Skip to content

Commit

Permalink
Added IDL
Browse files Browse the repository at this point in the history
  • Loading branch information
darrelmiller committed Oct 29, 2024
1 parent 2d6bb25 commit 0176460
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
73 changes: 73 additions & 0 deletions OpenAPIInterrface.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// OpenAPI Document Interface for creating/manipulating OpenAPI documents
interface IDocument {
// Create a new content object with the given value that belongs to the given parent element
IValueContent Create(IElement parentElement, IContent value);

// Create a new collection object as a child of the given parent element
ICollectionContent CreateCollection(IElement parentElement);

// Add a content object to a collection
IContent Add(ICollectionContent parentContent, IContent content);

// Remove a content object from a collection
void Remove(ICollectionContent parentContent, IContent content);

// Get value content from a parent collection
IValueContent? Get(ICollectionContent parent, IElement targetElement);

// Get a collection from a parent collection
ICollectionContent? GetCollection(ICollectionContent parent, IElement targetElement);

// Create/Get Relationships between content in different documents
void CreateRelationship(IDocument sourceDocument, IContent sourceContent, IDocument targetDocument, IContent targetContent);

// Remove Relationships between content in different documents
void RemoveRelationship(IDocument sourceDocument, IContent sourceContent, IDocument targetDocument, IContent targetContent);
};

// Interface for consuming API Descriptions
interface IADA {

// Get value content from a parent collection
IValueContent? Get(ICollectionContent parent, IElement targetElement);

// Get a collection from a parent collection
ICollectionContent? GetCollection(ICollectionContent parent, IElement targetElement);

// Validate a content object against a set of constraints
boolean Validate(IContent content, record<IElement, IConstraint> constraints);

}

// A semantic element in the description
interface IElement {
attribute DOMString Name;
};

// Some content of the description
interface IContent {
attribute IElement Element;
attribute any ValueType;
};

// A primitive value content
interface IValueContent : IContent {
attribute Any? Value;
};

// A collection of content objects
interface ICollectionContent : IContent {
attribute sequence<IContent> Contents;
};

interface IConstraint {
};

interface IValueConstraint : IConstraint {
attribute any ValueType;
};

interface ICollectionConstraint : IConstraint {
attribute sequence<parentElement>? AllowedChildren;
attribute sequence<parentElement>? RequiredChildren;
};
2 changes: 1 addition & 1 deletion tests/oasbridgetests/OpenApiDescriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void VerySimpleOpenApiWithPaths()

var paths = oad.Add(document, oad.CreateCollection(OpenApiKnownLocation.Paths));
var path = oad.Add(paths, oad.CreateCollection(OpenApiHttpSemantics.Path));
oad.Add(path, oad.Create(OpenApiHttpSemantics.PathKey, "/api/hello")); // This is a duplicate use of the key
oad.Add(path, oad.Create(OpenApiHttpSemantics.PathKey, "/api/hello"));
oad.Add(path, oad.Create(OpenApiDocumentation.Description, "This is a very simple API"));
oad.Add(path, oad.Create(OpenApiHttpSemantics.Get, oad.CreateCollection(OpenApiHttpSemantics.Operation)));
oad.Add(path, oad.Create(OpenApiHttpSemantics.Post, oad.CreateCollection(OpenApiHttpSemantics.Operation)));
Expand Down

0 comments on commit 0176460

Please sign in to comment.