Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Swagger/OAI Doc for OData in ASP.NET Core #5231


User avatar
0
chauey created

Using <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/doc/WebSite/OData-AspNetCore-Integration.md">https://github.com/aspnetboilerplate/as ... gration.md</a>, I was able to get OData endpoints up, but how can I get a Swagger/OAI doc for it? Any sample codes or guidance?

Also, when I try to get the $metadata, it doesn't show much: {"result": {"schemaElements": [{"declaredKey": [{"defaultValueString":null,"propertyKind":1,"type":{"isNullable":false,"definition":{"name":"Int32","namespace":"Edm","typeKind":1,"primitiveKind":9,"schemaElementKind":1,"fullName":"Edm.Int32"}}


3 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    I was able to get OData endpoints up, but how can I get a Swagger/OAI doc for it? Any sample codes or guidance?

    Try adding [RemoteService] attribute to your controller.

    Also, when I try to get the $metadata, it doesn't show much

    Answered in this SO question: <a class="postlink" href="https://stackoverflow.com/a/49559626/8601760">https://stackoverflow.com/a/49559626/8601760</a>

  • User Avatar
    0
    chauey created

    Thanks Aaron, the 2nd part seems to show the $metadata correctly now.

    However, for the 1st part, I believe still not working. I added the [RemoteService] attribute to an OData controller in my Web.Core project, but don't see any differences. Where is the OData Swagger supposed to show up? Along with the main Swagger doc/ui? Not sure I want it to be in the same doc in the future yet. but that's where I'm looking. Not sure how this is all connected yet. Thanks.

    ... [RemoteService] public class CodeLanguagesController : AbpODataEntityController<CodeLanguage>, ITransientDependency { ...

  • User Avatar
    0
    aaron created
    Support Team

    Try adding [Route] attribute to your method.