Skip to content

HTTP File Options

Configuration for generating HTTP files for NpgsqlRest endpoints, compatible with REST Client extensions and Visual Studio HTTP file support.

Overview

json
json
{
  "NpgsqlRest": {
    "HttpFileOptions": {
      "Enabled": false,
      "Option": "File",
      "Name": null,
      "NamePattern": "{0}_{1}",
      "CommentHeader": "Simple",
      "CommentHeaderIncludeComments": true,
      "FileMode": "Schema",
      "FileOverwrite": true,
      "OmitAutomaticParameters": false
    }
  }
}

Settings Reference

SettingTypeDefaultDescription
EnabledboolfalseEnable HTTP file generation.
Optionstring"File"Generation mode: "File", "Endpoint", or "Both".
NamestringnullBase file name. Uses database name if null, or "npgsqlrest" if no connection string.
NamePatternstring"{0}_{1}"File name pattern. {0} = database name, {1} = schema suffix (when FileMode is "Schema").
CommentHeaderstring"Simple"Comment header style: "None", "Simple", or "Full".
CommentHeaderIncludeCommentsbooltrueInclude routine comments in header (when CommentHeader is "Simple" or "Full").
FileModestring"Schema"File organization: "Database" or "Schema".
FileOverwritebooltrueOverwrite existing files.
OmitAutomaticParametersboolfalseOmit server-filled parameters from generated requests. See Omitting automatic parameters.

Generation Options

OptionDescription
FileGenerate HTTP files in the file system.
EndpointGenerate endpoint(s) serving HTTP file content.
BothGenerate both file system files and endpoints.

Comment Header Styles

StyleDescription
NoneNo comment header above requests.
SimpleAdd routine name, parameters, and return values (default).
FullAdd entire routine code as comment header.

File Mode

ModeDescription
DatabaseCreate one HTTP file for the entire database.
SchemaCreate one HTTP file per schema.

HTTP Files

HTTP files (.http) are supported by:

These files allow you to send HTTP requests directly from your editor for API testing and documentation.

Example Configuration

Generate HTTP files per schema with full routine documentation:

json
json
{
  "NpgsqlRest": {
    "HttpFileOptions": {
      "Enabled": true,
      "Option": "File",
      "Name": "myapi",
      "NamePattern": "{0}_{1}",
      "CommentHeader": "Full",
      "CommentHeaderIncludeComments": true,
      "FileMode": "Schema",
      "FileOverwrite": true
    }
  }
}

Generate a single HTTP file for the entire database:

json
json
{
  "NpgsqlRest": {
    "HttpFileOptions": {
      "Enabled": true,
      "Option": "File",
      "FileMode": "Database",
      "CommentHeader": "Simple"
    }
  }
}

Serve HTTP files as endpoints:

json
json
{
  "NpgsqlRest": {
    "HttpFileOptions": {
      "Enabled": true,
      "Option": "Endpoint"
    }
  }
}

Omitting Automatic Parameters

New in 3.18.2

OmitAutomaticParameters was added in 3.18.2 (also available on the Code Generation and OpenAPI generators). Default is false, so generated output is unchanged unless you opt in.

Some parameters are filled by the server and a client value would simply be ignored. When OmitAutomaticParameters is true, such a parameter is left out of the generated .http request (query string and request body) when it is automatic and optional. "Automatic" covers:

json
json
{
  "NpgsqlRest": {
    "HttpFileOptions": {
      "Enabled": true,
      "OmitAutomaticParameters": true
    }
  }
}

When every parameter of an endpoint is omitted, the request collapses to a bare URL with no query string or body.

Next Steps

Comments