# How to use Swagger Codegen for the integration via API

**Swagger Codegen** can generate code for many different programming languages. Some examples are Java, Python, JavaScript, Lua and PHP. More information can be found here: <https://swagger.io/tools/swagger-codegen/>

## How to generate Java-Code with Swagger Codegen 2

1\) git clone<https://github.com/swagger-api/swagger-codegen> (if necessary, install git before you execute this command)

2\) cd swagger-codegen

3\) mvn clean package (if necessary, install the newest version of Java and Apache Maven before you execute this command)

4\) mkdir ffng-java-client (You can choose this name or any other name for this directory. For convenience sake, we will refer to this directory as **ffng-java-client**)

5\) open **https\://\[your** **FactFinder** **setup here]/Fact-Finder/swagger-ui.html** (your FactFinder-URL with an appended **/swagger-ui.html**) in your favorite browser and copy the swagger-link that appears in the header of the page. In the example screenshot below, the linked text is **./rest/v5/swagger** (don't use the invalid URL that can be seen in the screenshot)

![](/files/8zZ3xn4xkxCftIynk4w6)

and execute:

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

You just generated example code for clients that can send all kinds of requests that FactFinder accepts.

6\) cd ffng-java-client

7\) copy the **Search with POST** code-example from **ffng-java-client/docs/SearchApi.md** into a java sourcecode file, for example **src/main/java/examplecompany/ExampleSearchClient.java** and insert necessary parts, like `package examplecompany;` and `public class ExampleSearchClient{`.

Make the generated classes, see (5), available in your project's classpath.

8a) fill in the correct credentials into the **basicAuth** part and delete the **OAuth2-part**

8b) set the correct name of the FactFinder channel.

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\) mvn clean install

10\) Run your first example search client. As maven was used to build the project, one easy way is to start your example search with maven, too:\
mvn exec:java -Dexec.mainClass=examplecompany.ExampleSearchClient

> (use mvn exec:java -D"exec.mainClass"=examplecompany.ExampleSearchClient if you are using **Window's Powershell**)

All other requests can be created in a similar manner. You can find code examples for them in the md-files in the generated docs-folder.

## How to generate Python-Code with Swagger CodeGen 2

1\) git clone<https://github.com/swagger-api/swagger-codegen> (if necessary install git before you execute this command)

2\) cd swagger-codegen

3\) mvn clean package (if necessary install the newest version of Java and Apache Maven before you execute this command)

4\) mkdir ffng-python-client

5\) open **https:FactFinder setup here]/Fact-Finder/swagger-ui.html** (your FactFinder-URL with an appended **/swagger-ui.html**) in your favorite browser and copy the swagger-link that appears in the header of the page. In the example screenshot below, the linked text is **./rest/v5/swagger** (don't use the invalid URL that can be seen in the screenshot)

![](/files/4lTQGek236GtEqQmjPAX)

and execute:

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

You just generated example code for clients that can send all kinds of requests that FactFinder accepts.

6\) cd ffng-python-client

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

8a) insert the following python-code into your python 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) fill in the correct credentials into the **basicAuth part** and delete the **OAuth2-part**

9b) set the correct name of the FactFinder channel.

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

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

by these 3 lines::

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

10. start your search-client and see the JSON-search result printed to standard-out.

All other requests can be created in a similar manner. You can find code examples for them in the md-files in the generated docs-folder.


---

# Agent Instructions: 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:

```
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>
```

The question should be specific, self-contained, and written in natural language.
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.
