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

enum support as parameters #626

Closed
3 tasks done
mselmanyildirim opened this issue Feb 28, 2023 · 3 comments · Fixed by #713
Closed
3 tasks done

enum support as parameters #626

mselmanyildirim opened this issue Feb 28, 2023 · 3 comments · Fixed by #713

Comments

@mselmanyildirim
Copy link

  • Version info - I'm using scribe 4.16.0 with laravel 10
  • I've read the documentation and I can't find details on how to achieve this.
  • I've searched the word enum in the documentation, but only found one occurence which was irrelevant.

The question is rather related to the generated openapi.yaml file.
As shown in the documentation page, openapi specification supports enums as parameters.

parameters:
  - in: query
    name: status
    schema:
      type: string
      enum: [approved, pending, closed, new]
      example: approved 

This helps the documentation to show dropdown menus for parameters having several predefined values, as in the following image:

image

Question
So, do we have a way to annotate a parameter in the comment blocks so that scribe generates the openapi.yaml file with enum value list? I guess I can override this via nn.yaml or config/scribe.php files, but it would be nice to do this via comment blocks.
Thanks!

@shalvah
Copy link
Contributor

shalvah commented Mar 4, 2023

Currently there isn't one, but we can figure out something.

@shalvah
Copy link
Contributor

shalvah commented Aug 20, 2023

Hey, I've implemented this. Can you try it out ( the enum branch)?

Any of these works:

#[BodyParam("status", enum: ['approved', 'pending', 'closed', 'new'])]
#[BodyParam("status", enum: ArticleStatus::class)]
/**
  @bodyParam status string Enum: approved, pending, closed, new
*/

@mselmanyildirim
Copy link
Author

Sorry for my late answer. I'll use it very soon. Thank you very much!

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