Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


Code Block
languagexml
titlecontroller.xml
collapsetrue
<controller xmlns="http://www.knubisoft.com/api/schema/controller">
    <overview>
        <description>
            Login API
        </description>
    </overview>

    <public>
        <!-- Login API flow  -->
        <include value="login"/>
    </public>
</controller>
Code Block
languagexml
titleendpoint.xml
collapsetrue
<endpoint xmlns="http://www.knubisoft.com/api/schema/endpoint">

    <swagger>
        <operationId>login</operationId>
        <summary>Logging in</summary>
        <description>Logging in with user credentials</description>
        <tags>
            <tag>Login</tag>
        </tags>
    </swagger>

    <responses>
        <_200>Success HTTP response from API with HTTP body</_200>
        <_404>Accepted HTTP call request but requested object is NOT FOUND</_404>
    </responses>

    <post>
        <response include="jwtTokensResponse.xml"/>
        <request include="loginRequest.xml"/>
    </post>
</endpoint>
Code Block
languagejava
titleLoginAPI
collapsetrue
package com.knubisoft.api.spec;

import com.fasterxml.jackson.core.type.TypeReference;
import com.knubisoft.api.dto.GenericApiResponse;
import com.knubisoft.api.dto.JwtTokensResponse;
import com.knubisoft.api.dto.LoginRequest;
import com.knubisoft.api.spec.stub.StubFactory;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Generated;
import javax.validation.Valid;

@Validated
@Generated(value = "com.knubisoft.api.generator.Main", date = "2022-08-16T14:48:12.549Z")
@RequestMapping("/api/v1/login")
public interface LoginAPI {

    @Operation(
            summary = "Logging in",
            description = "Logging in with user credentials",
            tags = {"Login"}
    )
    @ApiResponses(
            value = {
                    @ApiResponse(
                            responseCode = "200",
                            description = "Success HTTP response from API with HTTP body"),
                    @ApiResponse(
                            responseCode = "404",
                            description = "Accepted HTTP call request but requested object is NOT FOUND")
            }
    )
    @RequestMapping(
            consumes = "application/json",
            produces = "application/json",
            method = RequestMethod.POST)
    default ResponseEntity<GenericApiResponse<JwtTokensResponse>> login(
            @Valid @RequestBody LoginRequest requestBody) { 

        return ResponseEntity.ok(StubFactory.produce(new TypeReference<GenericApiResponse<JwtTokensResponse>>(){ }));
    } 

}




dto module

Dto module consists of generated classes(requests/responses and enums) that were described in api-spec module

Here is an example: