Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d1effd7
fix(pydantic): do not pass `by_alias` unless set
stainless-app[bot] Mar 16, 2026
f4e0bf7
fix(deps): bump minimum typing-extensions version
stainless-app[bot] Mar 16, 2026
8b957b0
chore(internal): tweak CI branches
stainless-app[bot] Mar 16, 2026
5e98894
fix: sanitize endpoint path params
stainless-app[bot] Mar 19, 2026
65a1e47
refactor(tests): switch from prism to steady
stainless-app[bot] Mar 19, 2026
d0ef767
chore(tests): bump steady to v0.19.4
stainless-app[bot] Mar 20, 2026
6d6fcb3
chore(tests): bump steady to v0.19.5
stainless-app[bot] Mar 20, 2026
82b4984
chore(internal): update gitignore
stainless-app[bot] Mar 23, 2026
3d0a67c
chore(tests): bump steady to v0.19.6
stainless-app[bot] Mar 23, 2026
edf0807
chore(ci): skip lint on metadata-only changes
stainless-app[bot] Mar 24, 2026
12eed8a
chore(tests): bump steady to v0.19.7
stainless-app[bot] Mar 24, 2026
3cd118a
feat(internal): implement indices array format for query and form ser…
stainless-app[bot] Mar 26, 2026
b1f6263
chore(tests): bump steady to v0.20.1
stainless-app[bot] Mar 31, 2026
2311bd8
chore(tests): bump steady to v0.20.2
stainless-app[bot] Mar 31, 2026
9a0e3e1
fix(client): preserve hardcoded query params when merging with user p…
stainless-app[bot] Apr 7, 2026
1b3db7b
fix: ensure file data are only sent as 1 parameter
stainless-app[bot] Apr 10, 2026
3e53f72
perf(client): optimize file structure copying in multipart requests
stainless-app[bot] Apr 17, 2026
afb0d6c
chore(tests): bump steady to v0.22.1
stainless-app[bot] Apr 17, 2026
e6be626
chore(internal): more robust bootstrap script
stainless-app[bot] Apr 22, 2026
5688176
fix: use correct field name format for multipart file arrays
stainless-app[bot] Apr 27, 2026
7abe70c
feat: support setting headers via env
stainless-app[bot] Apr 27, 2026
6c33d19
codegen metadata
stainless-app[bot] Apr 29, 2026
cf4f862
codegen metadata
stainless-app[bot] Apr 30, 2026
b94f0ed
chore(internal): reformat pyproject.toml
stainless-app[bot] Apr 30, 2026
1189baf
fix(client): add missing f-string prefix in file type error message
stainless-app[bot] May 8, 2026
3bc5e23
feat(internal/types): support eagerly validating pydantic iterators
stainless-app[bot] May 11, 2026
17dcee8
ci: pin GitHub Actions to commit SHAs
stainless-app[bot] May 12, 2026
57c1e3c
feat(api): switch to TypeScript SDK
stainless-app[bot] Jun 3, 2026
e5c705f
codegen metadata
stainless-app[bot] Jun 3, 2026
75e6694
feat(stlc): configurable CI runner and private-production-repo suppor…
stainless-app[bot] Jul 17, 2026
4585f59
release: 0.10.0
stainless-app[bot] Jul 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -16,10 +18,10 @@ jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/m3ter-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand All @@ -36,15 +38,15 @@ jobs:
run: ./scripts/lint

build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/m3ter-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand All @@ -65,7 +67,7 @@ jobs:
github.repository == 'stainless-sdks/m3ter-sdk-python' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

Expand All @@ -82,10 +84,10 @@ jobs:
test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/m3ter-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install Rye
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.repository == 'm3ter-com/m3ter-sdk-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Check release environment
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
_dev

__pycache__
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.9.0"
".": "0.10.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 286
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/rg%2Fm3ter-sdk-da8df9ce0e1464799f3b9feea8f957a3ca4c016fcba753ec71deb0ee2caf6536.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/rg/m3ter-sdk-8ed00aff39e19053e35301d739d96ff2bafb352273d647c86073ca879a1dad3f.yml
openapi_spec_hash: 3e75a21276e7cd06944188f512a7a4e3
config_hash: 10410ec7acfbc33ee5116775c6714440
config_hash: 5de7039a6202fb360a3970934cffb50e
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# Changelog

## 0.10.0 (2026-07-17)

Full Changelog: [v0.9.0...v0.10.0](https://github.com/m3ter-com/m3ter-sdk-python/compare/v0.9.0...v0.10.0)

### Features

* **api:** switch to TypeScript SDK ([57c1e3c](https://github.com/m3ter-com/m3ter-sdk-python/commit/57c1e3c32584a63fbf443ad0ee9826cec6c57948))
* **internal/types:** support eagerly validating pydantic iterators ([3bc5e23](https://github.com/m3ter-com/m3ter-sdk-python/commit/3bc5e2308d9c72883e96030e5772f1aa2b284fd7))
* **internal:** implement indices array format for query and form serialization ([3cd118a](https://github.com/m3ter-com/m3ter-sdk-python/commit/3cd118a9bc21161240103b20c337543971085869))
* **stlc:** configurable CI runner and private-production-repo support in workflow templates ([75e6694](https://github.com/m3ter-com/m3ter-sdk-python/commit/75e6694bd74dd1c17aa1b91831c30fd88721e91c))
* support setting headers via env ([7abe70c](https://github.com/m3ter-com/m3ter-sdk-python/commit/7abe70c78c984efc97fdf2bdef561b3b4b121a01))


### Bug Fixes

* **client:** add missing f-string prefix in file type error message ([1189baf](https://github.com/m3ter-com/m3ter-sdk-python/commit/1189baf65f73248e66dadb15c009efd8088893ed))
* **client:** preserve hardcoded query params when merging with user params ([9a0e3e1](https://github.com/m3ter-com/m3ter-sdk-python/commit/9a0e3e1b22996f808cdb22d4c3758c447d2bbd01))
* **deps:** bump minimum typing-extensions version ([f4e0bf7](https://github.com/m3ter-com/m3ter-sdk-python/commit/f4e0bf765ad9b9ac52fd1b20961502b0ffb4c5ab))
* ensure file data are only sent as 1 parameter ([1b3db7b](https://github.com/m3ter-com/m3ter-sdk-python/commit/1b3db7bf3a779a3880b5c1dfef4b0a2d6b0eb8a3))
* **pydantic:** do not pass `by_alias` unless set ([d1effd7](https://github.com/m3ter-com/m3ter-sdk-python/commit/d1effd76e6d5a03fad1a5d8419ca8b52816b39e9))
* sanitize endpoint path params ([5e98894](https://github.com/m3ter-com/m3ter-sdk-python/commit/5e988949139bf65480de9f9d2c698fee6e075439))
* use correct field name format for multipart file arrays ([5688176](https://github.com/m3ter-com/m3ter-sdk-python/commit/56881765eb3db683d4b8f01ecae568d1cc8edd47))


### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([3e53f72](https://github.com/m3ter-com/m3ter-sdk-python/commit/3e53f729f671160b65b4694a35c3c42501701d91))


### Chores

* **ci:** skip lint on metadata-only changes ([edf0807](https://github.com/m3ter-com/m3ter-sdk-python/commit/edf08074926089e25f642074a80c5af93cdafc79))
* **internal:** more robust bootstrap script ([e6be626](https://github.com/m3ter-com/m3ter-sdk-python/commit/e6be6268f7194886718d8aaf4cadf23762ea6bb4))
* **internal:** reformat pyproject.toml ([b94f0ed](https://github.com/m3ter-com/m3ter-sdk-python/commit/b94f0ed6582d97df147e15a60c94cb07c3e8ca2f))
* **internal:** tweak CI branches ([8b957b0](https://github.com/m3ter-com/m3ter-sdk-python/commit/8b957b0f1ae1fa8319ef24fc46b53a02f1c1a7e5))
* **internal:** update gitignore ([82b4984](https://github.com/m3ter-com/m3ter-sdk-python/commit/82b49845738e8adde71e3e754f88a908d038a07e))
* **tests:** bump steady to v0.19.4 ([d0ef767](https://github.com/m3ter-com/m3ter-sdk-python/commit/d0ef76766537a414720512f10fb4373194cfaf44))
* **tests:** bump steady to v0.19.5 ([6d6fcb3](https://github.com/m3ter-com/m3ter-sdk-python/commit/6d6fcb3631dbbbe79fdd7761ad9ed71be313b40b))
* **tests:** bump steady to v0.19.6 ([3d0a67c](https://github.com/m3ter-com/m3ter-sdk-python/commit/3d0a67c9d8f2d14fc1597617cae17f049538bb3b))
* **tests:** bump steady to v0.19.7 ([12eed8a](https://github.com/m3ter-com/m3ter-sdk-python/commit/12eed8a0fa281e595cbe7d89e25ff45a4eb5268d))
* **tests:** bump steady to v0.20.1 ([b1f6263](https://github.com/m3ter-com/m3ter-sdk-python/commit/b1f62634a84d9c9caa18728cfe11feffdb406cfa))
* **tests:** bump steady to v0.20.2 ([2311bd8](https://github.com/m3ter-com/m3ter-sdk-python/commit/2311bd8d4338a46ebef3d47110d078a84479d960))
* **tests:** bump steady to v0.22.1 ([afb0d6c](https://github.com/m3ter-com/m3ter-sdk-python/commit/afb0d6cc0f6b17f386ba162ffe5dbab68ccd10e2))


### Refactors

* **tests:** switch from prism to steady ([65a1e47](https://github.com/m3ter-com/m3ter-sdk-python/commit/65a1e47911b86486a1f6b8bd5bc8ae5feb520d15))

## 0.9.0 (2026-03-07)

Full Changelog: [v0.8.0...v0.9.0](https://github.com/m3ter-com/m3ter-sdk-python/compare/v0.8.0...v0.9.0)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ $ pip install ./path-to-wheel-file.whl

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.

```sh
$ ./scripts/mock
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@ and offers both synchronous and asynchronous clients powered by [httpx](https://

It is generated with [Stainless](https://www.stainless.com/).

## MCP Server

Use the M3ter MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.

[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=m3ter-sdk-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIm0zdGVyLXNkay1tY3AiXSwiZW52Ijp7Ik0zVEVSX0FQSV9LRVkiOiJNeSBBUEkgS2V5IiwiTTNURVJfQVBJX1NFQ1JFVCI6Ik15IEFQSSBTZWNyZXQiLCJNM1RFUl9BUElfVE9LRU4iOiJNeSBUb2tlbiIsIk0zVEVSX09SR19JRCI6Ik15IE9yZyBJRCJ9fQ)
[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22m3ter-sdk-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22m3ter-sdk-mcp%22%5D%2C%22env%22%3A%7B%22M3TER_API_KEY%22%3A%22My%20API%20Key%22%2C%22M3TER_API_SECRET%22%3A%22My%20API%20Secret%22%2C%22M3TER_API_TOKEN%22%3A%22My%20Token%22%2C%22M3TER_ORG_ID%22%3A%22My%20Org%20ID%22%7D%7D)

> Note: You may need to set environment variables in your MCP client.

## Documentation

The REST API documentation can be found on [www.m3ter.com](https://www.m3ter.com). The full API of this library can be found in [api.md](api.md).
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "m3ter"
version = "0.9.0"
version = "0.10.0"
description = "The official Python library for the m3ter API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -11,7 +11,7 @@ authors = [
dependencies = [
"httpx>=0.23.0, <1",
"pydantic>=1.9.0, <3",
"typing-extensions>=4.10, <5",
"typing-extensions>=4.14, <5",
"anyio>=3.5.0, <5",
"distro>=1.7.0, <2",
"sniffio",
Expand Down Expand Up @@ -168,7 +168,7 @@ show_error_codes = true
#
# We also exclude our `tests` as mypy doesn't always infer
# types correctly and Pyright will still catch any type errors.
exclude = ['src/m3ter/_files.py', '_dev/.*.py', 'tests/.*']
exclude = ["src/m3ter/_files.py", "_dev/.*.py", "tests/.*"]

strict_equality = true
implicit_reexport = true
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
Expand Down
26 changes: 13 additions & 13 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ fi

echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version
npm exec --package=@stdy/cli@0.22.1 -- steady --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online (max 30s)
# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
if ! kill -0 $! 2>/dev/null; then
echo
cat .stdy.log
exit 1
fi
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
echo "Timed out waiting for Steady server to start"
cat .stdy.log
exit 1
fi
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
fi
16 changes: 8 additions & 8 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
function steady_is_running() {
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
}

kill_server_on_port() {
Expand All @@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
if ! is_overriding_api_base_url && ! steady_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

Expand All @@ -36,19 +36,19 @@ fi
if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
elif ! steady_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
echo
fi

Expand Down
4 changes: 4 additions & 0 deletions src/m3ter/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ def _build_request(
files = cast(HttpxRequestFiles, ForceMultipartDict())

prepared_url = self._prepare_url(options.url)
# preserve hard-coded query params from the url
if params and prepared_url.query:
params = {**dict(prepared_url.params.items()), **params}
prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0])
if "_" in prepared_url.host:
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
Expand Down
24 changes: 23 additions & 1 deletion src/m3ter/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
RequestOptions,
not_given,
)
from ._utils import is_given, get_async_library
from ._utils import (
is_given,
is_mapping_t,
get_async_library,
)
from ._compat import cached_property
from ._models import FinalRequestOptions
from ._version import __version__
Expand Down Expand Up @@ -212,6 +216,15 @@ def __init__(
if base_url is None:
base_url = f"https://api.m3ter.com"

custom_headers_env = os.environ.get("M3TER_CUSTOM_HEADERS")
if custom_headers_env is not None:
parsed: dict[str, str] = {}
for line in custom_headers_env.split("\n"):
colon = line.find(":")
if colon >= 0:
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}

super().__init__(
version=__version__,
base_url=base_url,
Expand Down Expand Up @@ -1214,6 +1227,15 @@ def __init__(
if base_url is None:
base_url = f"https://api.m3ter.com"

custom_headers_env = os.environ.get("M3TER_CUSTOM_HEADERS")
if custom_headers_env is not None:
parsed: dict[str, str] = {}
for line in custom_headers_env.split("\n"):
colon = line.find(":")
if colon >= 0:
parsed[line[:colon].strip()] = line[colon + 1 :].strip()
default_headers = {**parsed, **(default_headers if is_mapping_t(default_headers) else {})}

super().__init__(
version=__version__,
base_url=base_url,
Expand Down
Loading
Loading