microsoft / typespec

https://typespec.io/
MIT License
4.56k stars 223 forks source link

[http-server-csharp] `Placeholder` is generated #5226

Open ArcturusZhang opened 2 days ago

ArcturusZhang commented 2 days ago

For todoApp, there is another Placeholder generated:

        [HttpGet]
        [Route("/items/{itemId}/attachments")]
        [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(Placeholder))]
        public virtual async Task<IActionResult> List(long itemId)
        {
            var result = await AttachmentsOperationsImpl.ListAsync(itemId);
            return Ok(result);
        }

I think this is generated from:

  @list op list(...PaginationControls): WithStandardErrors<TodoPage>;

model TodoPage {
    /** The items in the page */
    @pageItems items: TodoItem[];

    /** The number of items returned in this page */
    pageSize: int32;

    /** The total number of items */
    totalSize: int32;

    ...PaginationControls;

    /** A link to the previous page, if it exists */
    @prevLink
    prevLink?: url;

    /** A link to the next page, if it exists */
    @nextLink
    nextLink?: url;
  }
alias WithStandardErrors<T> = T | Standard4XXResponse | Standard5XXResponse;

I am not sure where it goes wrong from the spec which looks nothing special comparing with others in this spec.

ArcturusZhang commented 2 days ago

Its corresponding interface is generating JsonNode as a return type as well. I think JsonNode should work like a placeholder as well (we even do not have a using statement for it) This looks like the return type TodoPage is not properly handled and recognized.