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

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

Closed
ArcturusZhang opened this issue Nov 29, 2024 · 6 comments · Fixed by #5417
Closed

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

ArcturusZhang opened this issue Nov 29, 2024 · 6 comments · Fixed by #5417

Comments

@ArcturusZhang
Copy link
Member

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
Copy link
Member Author

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.

@markcowl
Copy link
Contributor

markcowl commented Dec 2, 2024

Cannot repro this issue. Appears to be fixed in my branch, at least

@ArcturusZhang
Copy link
Member Author

ArcturusZhang commented Dec 20, 2024

@ArcturusZhang
Copy link
Member Author

Apparently, this Placeholder is written here:

if (name === undefined) return "Placeholder";

this line might be called every time it has an anonymous model - and in this project there happens to have one: https://github.com/allenjzhang/typespec-e2e-demo/blob/2abc70f27d1e5344ce286462fa77ab887abbc228/todoApp/servers/aspnet/generated/models/Model0.cs

@ArcturusZhang
Copy link
Member Author

Cannot repro this issue. Appears to be fixed in my branch, at least

The reason you cannot reproduce might be you have the friendlyName decorator on the model - and it now has a name.
But in your latest change, the friendlyName is removed, therefore this issue pops up again.
I could add the decorator back, but this is still an issue to fix.

@markcowl markcowl linked a pull request Dec 21, 2024 that will close this issue
@markcowl
Copy link
Contributor

Yeah, this was fixed in my branch when you filed this issue i. All fixes in this PR: #5417

Generated code here: allenjzhang/typespec-e2e-demo#47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants