<commit_before>== Introduction

Consider the following Spring controller:footnote:[Throughout the documentation I've used Kotlin for brevity, but Apina
works perfectly with Java as well.]

[source,kotlin]
----
package hello

@RestController
class HelloController {

    @GetMapping(
    fun greet(@RequestParam name: String) =
        GreetingResponse(greeting = "Hello, $name!", mood = Mood.HAPPY)

    enum class Mood { HAPPY, SAD }

    class GreetingResponse(val greeting: String, val mood: Mood)

}
----

To generate TypeScript code from the controller, apply Apina's Gradle plugin:
footnote:[Again this is Kotlin, but using Groovy is similar enough.]

[source,kotlin]
[subs="verbatim,attributes"]
----
plugins {
    id("fi.evident.apina") version "{revnumber}"
}

tasks.apina {
    // Output file that Apina generates
    target = File(project(":frontend").projectDir, "gen/apina-api.ts")

    // Generate code for Angular
    platform = Platform.ANGULAR

    // Regex matching our controller classes
    endpoints = listOf("""hello\..+""")
}
----

Next, import generated `ApinaModule` from your Angular module:

[source,typescript]
----
import { ApinaModule } from '../gen/apina-api';

@NgModule({
    imports: [
        ...
        ApinaModule
    ],
    ...
})
class MyModule { }
----

Finally, inject the service generated by Apina and use it your own code:

[source,typescript]
----
import { Component } from "@angular/core";
import { HelloEndpoint, GreetingResponse } from '../gen/apina-api';

@Component({
    selector: 'my-greeting',
    template: `<span *ngIf="reseponse$ | async as response">{{response.greeting}}</span>`<commit_msg>Fix typo in manual<commit_after>== Introduction

Consider the following Spring controller:footnote:[Throughout the documentation I've used Kotlin for brevity, but Apina
works perfectly with Java as well.]

[source,kotlin]
----
package hello

@RestController
class HelloController {

    @GetMapping(
    fun greet(@RequestParam name: String) =
        GreetingResponse(greeting = "Hello, $name!", mood = Mood.HAPPY)

    enum class Mood { HAPPY, SAD }

    class GreetingResponse(val greeting: String, val mood: Mood)

}
----

To generate TypeScript code from the controller, apply Apina's Gradle plugin:
footnote:[Again this is Kotlin, but using Groovy is similar enough.]

[source,kotlin]
[subs="verbatim,attributes"]
----
plugins {
    id("fi.evident.apina") version "{revnumber}"
}

tasks.apina {
    // Output file that Apina generates
    target = File(project(":frontend").projectDir, "gen/apina-api.ts")

    // Generate code for Angular
    platform = Platform.ANGULAR

    // Regex matching our controller classes
    endpoints = listOf("""hello\..+""")
}
----

Next, import generated `ApinaModule` from your Angular module:

[source,typescript]
----
import { ApinaModule } from '../gen/apina-api';

@NgModule({
    imports: [
        ...
        ApinaModule
    ],
    ...
})
class MyModule { }
----

Finally, inject the service generated by Apina and use it your own code:

[source,typescript]
----
import { Component } from "@angular/core";
import { HelloEndpoint, GreetingResponse } from '../gen/apina-api';

@Component({
    selector: 'my-greeting',
    template: `<span *ngIf="response$ | async as response">{{response.greeting}}</span>`
{'fraction_non_alphanumeric': 0.13567534827377348, 'fraction_numerical': 0.0, 'mean_word_length': 3.5621546961325965, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7577055', 'n_tokens_mistral': 1029, 'n_tokens_neox': 987, 'n_words': 300}