code: public function withMediaType(string $mediaType): self
      {
          if (!$encoding = $this->api->getEncodings()->find($mediaType)) {
              throw new \InvalidArgumentException(
                  "Media type {$mediaType} is not valid for API {$this->api->getName()}."
              );
          }
  
          $codec = $this->factory->createCodec(
              $this->api->getContainer(),
              $encoding,
              null
          );
  
          return $this->withCodec($codec);
      }
docs: Send a response with the supplied media type content.
  
  @param string $mediaType
  @return $this