> For the complete documentation index, see [llms.txt](https://docs.fact-finder.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fact-finder.com/integration/factfinder-search-integration/integrating-the-search-into-the-shop-system/how-to-use-swagger-codegen-for-the-integration-via-api.md).

# How to use Swagger Codegen for the integration via API

**Swagger Codegen** can generate client code for many programming languages, including Java, Python, JavaScript, Lua, and PHP. Learn more here: <https://swagger.io/tools/swagger-codegen/>

## How to generate Java code with Swagger Codegen 2

1\) Clone the Swagger Codegen repository:

`git clone https://github.com/swagger-api/swagger-codegen`

If needed, install Git first.

2\) Move into the repository:

`cd swagger-codegen`

3\) Build the project:

`mvn clean package`

If needed, install a current Java version and Apache Maven first.

4\) Create an output directory:

`mkdir ffng-java-client`

You can choose any directory name. For convenience, this guide uses **ffng-java-client**.

5\) Open **https\://\[your FactFinder setup here]/Fact-Finder/swagger-ui.html** in your browser and copy the Swagger link shown in the page header. In the screenshot below, the linked text is **./rest/v5/swagger**. Do not use the invalid URL shown in the screenshot.

![](/files/4lTQGek236GtEqQmjPAX)

Then run:

`java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i [your swagger-link here] -l java -o ./ffng-java-client`

This generates example client code for all request types supported by FactFinder.

6\) Move into the generated client directory:

`cd ffng-java-client`

7\) Copy the **Search with POST** example from **ffng-java-client/docs/SearchApi.md** into a Java source file, for example **src/main/java/examplecompany/ExampleSearchClient.java**. Add the missing parts, such as `package examplecompany;` and `public class ExampleSearchClient {`.

Make the generated classes from step 5 available in your project’s classpath.

8a) Enter the correct credentials in the **basicAuth** section and remove the **OAuth2** section.

8b) Set the correct FactFinder channel name.

8c) Insert this or a similar code snippet to set the search query:

```language-plaintext
SearchParams searchParams= new SearchParams();
searchParams.setQuery("*");
searchRequest.setParams(searchParams);
```

9\) Build the client:

`mvn clean install`

10\) Run your first example search client. Since Maven was used to build the project, an easy option is to start it with Maven as well:\
`mvn exec:java -Dexec.mainClass=examplecompany.ExampleSearchClient`

> Use `mvn exec:java -D"exec.mainClass"=examplecompany.ExampleSearchClient` if you are using **Windows PowerShell**.

All other requests can be created in a similar way. You can find code examples for them in the Markdown files in the generated `docs` folder.

## How to generate Python code with Swagger Codegen 2

1\) Clone the Swagger Codegen repository:

`git clone https://github.com/swagger-api/swagger-codegen`

If needed, install Git first.

2\) Move into the repository:

`cd swagger-codegen`

3\) Build the project:

`mvn clean package`

If needed, install a current Java version and Apache Maven first.

4\) Create an output directory:

`mkdir ffng-python-client`

5\) Open **https\://\[your FactFinder setup here]/Fact-Finder/swagger-ui.html** in your browser and copy the Swagger link shown in the page header. In the screenshot below, the linked text is **./rest/v5/swagger**. Do not use the invalid URL shown in the screenshot.

![](/files/4lTQGek236GtEqQmjPAX)

Then run:

`java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i [your swagger-link here] -l python -o ./ffng-python-client`

This generates example client code for all request types supported by FactFinder.

6\) Move into the generated client directory:

`cd ffng-python-client`

7\) Copy the **Search with POST** example from **ffng-python-client/docs/SearchApi.md** into a Python source file, for example **my-example-search-client.py**.

8a) Insert the following Python code into your file:

```language-python
class MyConfiguration(swagger_client.Configuration):
 def auth_settings(self):
 return {
 'basicAuth':
 {
 'type': 'basic',
 'in': 'header',
 'key': 'Authorization',
 'value': self.get_basic_auth_token()
 }
 }
```

8b) replace the line:

```language-python
configuration = swagger_client.Configuration()
```

with the line:

```language-python
configuration = MyConfiguration()
```

9a) Enter the correct credentials in the **basicAuth** section and remove the **OAuth2** section.

9b) Set the correct FactFinder channel name.

9c) Insert this or a similar code snippet to set the search query by replacing this line:

```language-python
search_request = swagger_client.SearchRequest()
```

with these three lines:

```language-python
query = "*"
search_params = swagger_client.SearchParams(query=query)
search_request = swagger_client.SearchRequest(search_params)
```

10. Start your search client and review the JSON search result printed to standard output.

All other requests can be created in a similar way. You can find code examples for them in the Markdown files in the generated `docs` folder.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fact-finder.com/integration/factfinder-search-integration/integrating-the-search-into-the-shop-system/how-to-use-swagger-codegen-for-the-integration-via-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
