Mattias Sehlstedt 7c4ada33c4
[Java] [SpringClient] Introduce setting for sealed oneOf interfaces for Spring clients (#21586)
* Add setting for generating the oneOf interfaces as sealed interfaces

* Generate samples

* Add internal java17 additionalProperty setting

* Move samples to highlight that they do not use the petstore

* Align documentation

* Update samples

* Align documentation

* Update mustache files and samples to change gradle settings to java17
2025-07-28 20:03:54 +08:00

3.4 KiB

FooApi

All URIs are relative to http://localhost:8080

Method HTTP request Description
createFoo POST /foo Create a Foo
getAllFoos GET /foo GET all Foos

createFoo

FooRefOrValue createFoo(foo)

Create a Foo

Example

// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FooApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost:8080");

        FooApi apiInstance = new FooApi(defaultClient);
        Foo foo = new Foo(); // Foo | The Foo to be created
        try {
            FooRefOrValue result = apiInstance.createFoo(foo);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling FooApi#createFoo");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
foo Foo The Foo to be created [optional]

Return type

FooRefOrValue

Authorization

No authorization required

HTTP request headers

  • Content-Type: application/json;charset=utf-8
  • Accept: application/json

HTTP response details

Status code Description Response headers
201 Error -

getAllFoos

List<FooRefOrValue> getAllFoos()

GET all Foos

Example

// Import classes:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.Configuration;
import org.openapitools.client.models.*;
import org.openapitools.client.api.FooApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost:8080");

        FooApi apiInstance = new FooApi(defaultClient);
        try {
            List<FooRefOrValue> result = apiInstance.getAllFoos();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling FooApi#getAllFoos");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

This endpoint does not need any parameter.

Return type

List<FooRefOrValue>

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json;charset=utf-8

HTTP response details

Status code Description Response headers
200 Success -