Skip to content

ContentType defined in HttpApiSchema.withEncoding isn't returned in the endpoint response #5908

@MiguelKorn

Description

@MiguelKorn

What version of Effect is running?

3.19.9

What steps can reproduce the bug?

When trying to change the contentType of an ApiEndpoint, the response contentType is always application/json instead of the changed contentType.

const MyEndpoint = HttpApiEndpoint.get("foo")`/foo`
  .addSuccess(
    MyResultSchema.pipe(
      HttpApiSchema.withEncoding({
        kind: "Json",
        contentType: "application/scim+json", 
      }),
    ),
  )

Discussed this in the discord, i got pointed at changing the kind to Text. That returns the given contentType, but then the returned value isn't json anymore obviously.

What is the expected behavior?

returned contentType that is defined in this example "application/scim+json"

What do you see instead?

returned contentType is always "application/json"

Additional information

Also, when requesting an endpoint with contentType application/scim+json (given snippet above), the body isn't parsed as json and the schema (MyResultSchema) will fail. While its kind of expected based on the source code, shouldn't we be able to tell the endpoint how to parse the given contentType if its not one of the default ones?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions