OpenAPI 3.2 QUERY
Client Generator
Generate typed clients that send HTTP QUERY with a request body. Try a product search defined with a native query: operation or compare the output for eight client targets.
openapi: 3.2.0
info: { title: Product Catalog, version: 1.0.0 }
servers:
- url: https://catalog.example.com
paths:
/products:
query:
operationId: searchProducts
tags: [catalog]
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/ProductFilter' }
responses:
'200':
description: Matching products
content:
application/json:
schema: { type: array, items: { $ref: '#/components/schemas/Product' } } public searchProducts(body: ProductFilter): Observable<Array<Product>> {
return this.execute<Array<Product>>('/products', body, { method: 'QUERY' });
}A typed filter for the JSON body
The catalog API requires a term and accepts an optional maxPrice. The Fetch generator emits this TypeScript model and takes it as the body of searchProducts.
export interface ProductFilter {
term: string;
maxPrice?: number;
}
One path with QUERY, GET, and POST
Each operation in the catalog fixture keeps its declared HTTP method and body contract.
query:
operationId: searchProducts
tags: [catalog]
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/ProductFilter' }
responses:
'200':
description: Matching products
content:
application/json:
schema: { type: array, items: { $ref: '#/components/schemas/Product' } }export async function searchProducts(apiClient: ApiClient, body: ProductFilter): Promise<Array<Product>> {
return apiClient.request<Array<Product>>({
method: 'QUERY',
url: '/products',
body: body
});
}Compare the generated clients
The service sends QUERY with a typed body. The signal resource sends the same method when its filter signal has a value.
import { BASE_URL } from '../injection-token';
import { Injectable, Signal } from '@angular/core';
import { Observable } from 'rxjs';
import { Inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpResourceRef } from '@angular/common/http';
import { BaseApiService } from './base-api.service';
import { ProductFilter } from '../models/product-filter';
import { Product } from '../models/product';
import { NewProduct } from '../models/new-product';
@Injectable()
export class CatalogService extends BaseApiService {
constructor(
protected override readonly http: HttpClient,
@Inject(BASE_URL) baseUrl: string
) {
super(http, baseUrl);
}
public searchProducts(body: ProductFilter): Observable<Array<Product>> {
return this.execute<Array<Product>>('/products', body, { method: 'QUERY' });
}
public listProducts(): Observable<Array<Product>> {
return this.execute<Array<Product>>('/products', undefined, { method: 'get' });
}
public createProduct(body: NewProduct): Observable<Product> {
return this.execute<Product>('/products', body);
}
public searchProductsResource(body: Signal<ProductFilter | undefined>): HttpResourceRef<Array<Product>> {
return this.buildResource<Array<Product>>(() => {
const bodyValue = body();
if (typeof bodyValue === 'undefined') {
return undefined;
}
return {
url: this.buildUrl(`/products`),
method: 'QUERY',
body: bodyValue,
};
},
{ defaultValue: [] });
}
public listProductsResource(): HttpResourceRef<Array<Product>> {
return this.buildResource<Array<Product>>(() => {
return this.buildUrl(`/products`);
},
{ defaultValue: [] });
}
}
Generate QUERY clients in your build
Each package supports OpenAPI 3.2 QUERY operations. These examples come from the hosted converter. Generated files can vary with the installed package version and options.
@metaengine/openapi-angularInstall the Angular client generator and configure it for your project.Package docs & options@metaengine/openapi-reactInstall the React client generator and configure it for your project.Package docs & options@metaengine/openapi-fetchInstall the Fetch client generator and configure it for your project.Package docs & optionsMetaEngine.CSharp.OpenApi.HttpClient.ToolInstall the C# client generator and configure it for your project.Package docs & optionseu.metaengine:metaengine-openapi-java-spring-maven-pluginInstall the Java client generator and configure it for your project.Package docs & optionseu.metaengine:metaengine-openapi-kotlin-ktor-maven-pluginInstall the Kotlin client generator and configure it for your project.Package docs & optionsmetaengine-openapi-httpxInstall the Python client generator and configure it for your project.Package docs & optionsmetaengine-openapi-go-nethttpInstall the Go client generator and configure it for your project.Package docs & optionsUsing the HTTP QUERY method
The sample uses a catalog search with a required JSON filter.
QUERY as a safe, idempotent method that asks a resource to process a request body. A catalog search can send structured filters in JSON and return matching products without requesting a state change.Same engine, other stacks.
Every converter runs the same spec-to-IR pipeline. Pick another source format or target stack.
Generate a client from your OpenAPI spec
The converter UI runs in your browser. When you generate, your specification (or its URL), selected options, and any custom content you explicitly include are sent over HTTPS to the MetaEngine API. The API processes the payload ephemerally; specifications and generated code are not persisted or logged.
Read the public privacy policy