Giter VIP home page Giter VIP logo

hal's Introduction

Hi there πŸ‘‹

I used to be a Microsoft Most Valuable Professional (MVP) from the year 2012 to 2019, mostly focused on Development Technologies. Now I am currently working for PerkinElmer Informatics R&D as a Principal Software Engineer.

I am a fan of Microsoft development technologies, specifically, .NET (C#). I am also interested in software architecture, OOAD, DDD, big data, AI and agile development methodologies.

hal's People

Contributors

daxnet avatar drasive avatar jonathanschein avatar manuel-guilbault avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hal's Issues

Swagger UI response Type for HAL Resources

Problem statement:

When using swagger with [ProducesResponseType(typeof(MeetingRoom), StatusCodes.Status200OK)]
The generated docs would produce a schema such as:

{
  "id": 0,
  "name": "string",
  "seats": 0
}

Where as in reality the response type is a wrapped HAL resource such as:

{
  "_links": {
    "self": {
      "href": string
    }
  },
  "id": number,
  "name": string,
  "seats": number
}

What approach would you suggest for integrating with swagger docs?

Couple of things come to my mind:

  1. Custom ActionAttribute aka ProducesHalResponseType(typeof(MeetingRoom), StatusCodes.Status200OK)] which would attempt describe it accordingly.
  2. Custom converters for serialization.

List of embedded resources with only one element

When generating a Json HAL with a list of two or more embedded resources (like orders example), the library returns an array of embedded objects:

{ "_links": { "self": { "href": "/orders" }, "curies": [ { "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true } ], "next": { "href": "/orders?page=2" }, "ea:find": { "href": "/orders{?id}", "templated": true } }, "currentlyProcessing": 14, "shippedToday": 20, "_embedded": { "ea:order": [ { "_links": { "self": { "href": "/orders/123" }, "ea:basket": { "href": "/baskets/98712" }, "ea:customer": { "href": "/customers/7809" } }, "total": 30.0, "currency": "USD", "status": "shipped" }, { "_links": { "self": { "href": "/orders/124" }, "ea:basket": { "href": "/baskets/97213" }, "ea:customer": { "href": "/customers/12369" } }, "total": 20.0, "currency": "USD", "status": "processing" } ] } }

but when the list has only one element, the library returns an embedded object instead of an array with only one element:

{ "_links": { "self": { "href": "/orders" }, "curies": [ { "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true } ], "next": { "href": "/orders?page=2" }, "ea:find": { "href": "/orders{?id}", "templated": true } }, "currentlyProcessing": 14, "shippedToday": 20, "_embedded": { "ea:order": { "_links": { "self": { "href": "/orders/123" }, "ea:basket": { "href": "/baskets/98712" }, "ea:customer": { "href": "/customers/7809" } }, "total": 30.0, "currency": "USD", "status": "shipped" } } }

I think it sholud return an array with one order, to be consistent with the previous result. ΒΏIs there any way to force the API to generate an array with one object instead?

Those Json Hal examples were generated using then Example test.

Thanks in advance!

Add support of .NET 6 to Hal.AspNetCoreIntegration

Previously we used version 2.1.4 of Hal.AspNetCoreIntegration that supported .NET 6, but now we need to use a fresh one (2.2.0) that supports serializer configuration and unfortunately compatible with .NET 7 and .NET 8 only.
Is there is chance to add support of .NET 6 also?

The library doesn't support serializing enums as strings

If resource is built from type that contains any enum, the result json will contain the integer value of the enum rather than its string name. Unfortunately, this behaviour can not be fixed by any settings in the application. According to my investigation, the reason of such behaviour is the fact that there is no way to setup JsonSerializerSettings field in SupportsHalAttribute and converters field in Resource class.

I tried to fix it in the fork by adding StringEnumConverter to converters and it resolved the issue.

Is it possible to make these fields configurable outside?

Error with fluent api

hi

im trying the following with fluent api

var reportsbuilder = new ResourceBuilder();
var reportresource = reportsbuilder.WithState(new { reportName = itemClientReport.ReportKey })
.AddSelfLink().WithLinkItem("/")
.AddLink("").WithLinkItem("")
.AddEmbedded("_report");

and after

reportresource.Resource(new ResourceBuilder().WithState(new { id = 1}));
string data = reportresource.Build().ToString();

so it's not taking the last line, the embedded it's giving me null .

but i put the complete

var reportsbuilder = new ResourceBuilder();
var reportresource = reportsbuilder.WithState(new { reportName = itemClientReport.ReportKey })
.AddSelfLink().WithLinkItem("/")
.AddLink("").WithLinkItem("")
.AddEmbedded("_report");
.Resource(new ResourceBuilder().WithState(new { id = 1 }));

string data = reportresource.Build().ToString();

it works by this way.

i need it separately because i need to add resources dependig of conditions into the embedded.

Any ideas?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.