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

Invalid OpenAPI file generated when path parameters are included. #668

Open
fortyCakes opened this issue Sep 30, 2024 · 0 comments
Open

Comments

@fortyCakes
Copy link

Describe the issue
When I include path parameters, the file generated does not meet OpenApi spec because the "required: true" is omitted. It looks like the "Required" is being ignored entirely for this parameter, as it also doesn't have a required annotation in the Swagger UI.

To Reproduce
Steps to reproduce the behavior:

 [OpenApiOperation(
     operationId: "ListUnread",
     tags: new[] { "notification" },
     Summary = "Lists unread notifications",
     Description = "Lists all unread notifications assigned to the calling user."
     )]
 [OpenApiParameter("tenantId", Description = "The tenant ID of the current customer.", Type = typeof(Guid), Required = true, In = ParameterLocation.Path)]
 [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(IEnumerable<NotificationTableEntity>), Summary = "Unread notifications", Description = "This returns a list of notifications.")]
 [Function("ListUnread")]
 public IActionResult ListUnread(
     [HttpTrigger(AuthorizationLevel.User, "get", Route = "{tenantId:guid}/notification/unread")] HttpRequest req, Guid tenantId,
     ILogger log)
 {

Generate a v3.yaml (or any other output) file:

paths:
  '/{tenantId}/notification/unread':
    get:
      tags:
        - notification
      summary: Lists unread notifications
      description: Lists all unread notifications assigned to the calling user.
      operationId: ListUnread
      parameters:
        - name: tenantId
          in: path
          description: The tenant ID of the current customer.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: This returns a list of notifications.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/notificationTableEntity'
          x-ms-summary: Unread notifications

Expected behavior
The "parameters" section should have "required: true" under the parameter.

Environment (please complete the following information, if applicable):

  • OS: happens on local Windows build and building on ubuntu-latest
  • Version v1.5.1, v2.0.0-preview2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant