Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for documentation to ODataConventionModelBuilder #26

Closed
LianwMS opened this issue Jan 12, 2015 · 6 comments
Closed

Add support for documentation to ODataConventionModelBuilder #26

LianwMS opened this issue Jan 12, 2015 · 6 comments
Assignees
Milestone

Comments

@LianwMS
Copy link
Contributor

LianwMS commented Jan 12, 2015

This can be done easily by looking for the System.ComponentModel.Description
attribute on entities and properties, and using the EDM model's
SetDocumentation() method.

Work Item Details

Original CodePlex Issue: Issue 784
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Jan 18, 2013 at 9:44 AM
Reported by: thargy
Updated on: Feb 7, 2014 at 7:01 PM
Updated by: troydalldorf

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2013-04-02 03:06:18 UTC, HongmeiG commented:

Nice feature request Thargy! Today you could add the documentation yourself after the model is built by the conventional model builder.

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2013-04-09 08:35:58 UTC, raghuramn commented:

private static IEdmModel GetEdmModel()
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet("Customers");
builder.EntitySet("Orders");

IEdmModel model = builder.GetEdmModel();
DocumentModel(model);

return model;

}

private static void DocumentModel(IEdmModel model)
{
foreach (IEdmType edmType in model.SchemaElements.OfType())
{
Type clrType = model.GetAnnotationValue(edmType).ClrType;

    model.SetDocumentation(edmType, new EdmDocumentation("Summary", "Description"));
}

}

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2013-09-06 05:56:56 UTC, KevinBurton commented:

So for the slow how is this used? For example one of the resources that I am adding looks like:
var schedules = modelBuilder.EntitySet("Schedules");

A portion of the ScheduleRepresentation looks like:
public class ScheduleRepresentation
{
[Key]
public string Id { get; set; }
public string Name { get; set; }
public string TitleType { get; set; }
public string FolderId { get; set; }

Is it as simple as adding /// comments to each property? If so should they be ///

?

Thank you.

@LianwMS
Copy link
Contributor Author

LianwMS commented Jan 12, 2015

On 2013-09-06 07:23:08 UTC, raghuramn commented:

@kevin: we don't automatically parse the xml documentation and populate the model with it. The above sample shows how to annotate an EDM model with documentation. You should write code to parse the xml doc file or wherever your documentation lives and
annotate your model.

@LianwMS LianwMS added this to the vNext milestone Jan 12, 2015
@xuzhg xuzhg self-assigned this May 31, 2016
@jeffabailey
Copy link

@LianwMS I'm trying to use your method posted on Jan 11th to simply set the documentation. I am finding that the SetDocumentation method is internal, how then can this be done at this point?

Here is the Edm version I'm using.

Here is the static method.

internal static void SetDocumentation(this IEdmModel model, IEdmElement element, IEdmDocumentation documentation)

I've been trying to muck around to find how to do this but it's slow going.

@xuzhg
Copy link
Member

xuzhg commented May 2, 2018

Close this because OData V4 spec doesn't have Document element.

@xuzhg xuzhg closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants