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

How to add operationId in Plumber? #939

Open
apriandito opened this issue Dec 8, 2023 · 4 comments
Open

How to add operationId in Plumber? #939

apriandito opened this issue Dec 8, 2023 · 4 comments
Labels
difficulty: novice Anyone could help effort: low < 1 day of work theme: OpenAPI pertains to OpenAPI
Milestone

Comments

@apriandito
Copy link

I try to connect my plumber api to ChatGPT/OpenAI Action, but it show error "method put is missing operationId; skipping"
image

this is my openapi json link https://api.socialx.id/openapi.json.

how to solve it?

Several previous issues have asked this. #856 but it still doesn't seem to work

@meztez
Copy link
Collaborator

meztez commented Dec 10, 2023

You can edit the spec to match your requirement https://www.rplumber.io/reference/pr_set_api_spec.html.

@apriandito
Copy link
Author

ahh i see just in case someone have same problem like me. here some reference.

pr() %>%
  pr_set_api_spec(function(spec) {
    spec$info$title <- "Nama API"
    spec$info$description <- "Deskripsi API"
    spec$info$termsOfService <- "https://contoh.com/tos"
    
    # Set response schema for /hello
    spec$paths$`/hello`$get$responses$`200`$content$`application/json`$schema <- list(type = "string")
    
    # Set response schema for /add
    spec$paths$`/add`$post$responses$`200`$content$`application/json`$schema <- list(type = "number")
    
    spec$paths$`/hello`$get$operationId <- "hello_world"
    spec$paths$`/add`$post$operationId <- "add_numbers"
    spec
  }) %>%
  pr_get("/hello", function(req) {
    "Hello World!"
  }) %>%
  pr_post("/add", function(req) {
    as.numeric(req$POST$body$a) + as.numeric(req$POST$body$b)
  }) %>%
  pr_run(port = 8000)

@meztez meztez reopened this Dec 11, 2023
@meztez
Copy link
Collaborator

meztez commented Dec 11, 2023

Add operationId to generated spec:
https://spec.openapis.org/oas/latest.html#fixed-fields-7

@meztez meztez added theme: OpenAPI pertains to OpenAPI difficulty: novice Anyone could help effort: low < 1 day of work labels Dec 11, 2023
@meztez meztez added this to the v1.3.0 milestone Dec 11, 2023
@adejumoridwan
Copy link

@meztez I would like to work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: novice Anyone could help effort: low < 1 day of work theme: OpenAPI pertains to OpenAPI
Projects
None yet
Development

No branches or pull requests

3 participants