Skip to content

inconsistent "Argument" documentation #87

Open

Description

@r2evans

In the annotations page, the "@Body" tag (among a few) suggests it can be Name[:Type][(Default)][*][Description]. In my experience, that means that:

  • Name is required
  • if you want a Type, it must be preceded by a colon
  • if you want a Default value, it must be enclosed in parens
  • if you want it to be required, add * after all of name, type, default (some optional) and before an optional description
  • if you want a Description, it must be enclosed in brackets

However, the verbiage states

If a single @Body tag is used the Name can be omitted to indicate that the body is not a named object but simply an instance of the given Type

Ignoring the "name is required" part, it then makes sense that in this case I should do #* @body :string, but that fails with

Caused by error in `type_caster(content$schema, isTRUE(desc$required), loc = "body")`:
! argument "name" is missing, with no default

What works is #* @body string, but that could mean Name="string" or Type="string".

I suggest plumber2 supports the format directed by the "Argument" string that says the type needs to be preceded by the Name. Whether or not you impose stricter parsing is a discussion for backward compatibility.


But even with that, @body, @body quux:quux, @body quux, and @body binary all make no difference to me, the function(body) still works as one might think. For this, Is my @parser raw impacting things?

plumber2::register_parser(
  name       = "raw",
  fun        = function() function(raw, directives) raw,
  mime_types = "*/*",
  default    = FALSE
)

(Do you think adding a native parser that always always always returns "raw binary" regardless of what is claimed? "octet" fails when the caller specifies a content-type, I want to ignore what the caller claims.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions