question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[JAVA] [SPRING] Missed ApiUtil when generated interface only

See original GitHub issue
Description
task buildAPI(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
    verbose = true
    generatorName = "spring"

    systemProperties = [apis: ""]

    additionalProperties = [
            "sourceFolder"  : "",
            "interfaceOnly" : "true",
    ]

}

Generates code:

    @ApiOperation(value = "List all pets", nickname = "listPets", notes = "", response = Error.class, tags={ "pets", })
    @ApiResponses(value = { 
        @ApiResponse(code = 200, message = "unexpected error", response = Error.class) })
    @RequestMapping(value = "/pets",
        produces = { "application/json" }, 
        method = RequestMethod.GET)
    default ResponseEntity<Error> listPets() {
        getRequest().ifPresent(request -> {
            for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
                if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                    ApiUtil.setExampleResponse(request, "application/json", "{  \"code\" : 0,  \"message\" : \"message\"}");
                    break;
                }
            }
        });
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

    }

But class ApiUtil is not generated.

openapi-generator version

openapiGeneratorVersion = ‘3.2.0-SNAPSHOT’

OpenAPI declaration file content or url

openapi: "3.0.0"
info:
  version: 1.0.0
  title: IBAN Register
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      responses:
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Error:
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string

Suggest a fix/enhancement

Probably duplicate of #386

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

15reactions
MichalFoksacommented, Jun 20, 2019

I prefer solution when generateSupportingFiles is false then default interface implementation does not rely on ApiUtil class.

7reactions
coolaidercommented, Sep 27, 2018

same issue setting the property generateSupportingFiles=true helped

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove ApiUtil.java from openApi ... - Stack Overflow
Answering my own question. I had to do following things: Increase Open Api version in build.gradle. This is important becuase it was not ......
Read more >
Documentation for the spring Generator
helpTxt, Generates a Java SpringBoot Server application using the SpringDoc ... interfaceOnly, Whether to generate only API interface stubs ...
Read more >
Open API Server Implementation Using OpenAPI Generator
Learn how to generate a Spring-based server stub from a YAML specification using the OpenAPI generator's Maven plugin.
Read more >
17. Web MVC framework - Spring
The model (the M in MVC) is a Map interface, which allows for the complete ... configuration of both framework and application classes...
Read more >
FileNet P8 - Getting Started - IBM
Important: In the development of your applications, use only the exposed classes and interfaces that are documented in the Content Engine Java™ and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found