OpenAPITools / OpenAPITools/openapi-generator

[BUG] package io.swagger.v3.oas.annotations.media does not exist

Open
#16,932 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Generating an example (pet store) with maven plugin produces the following exception:
api/dto/ApiResponseDTO.java:[11,43] package io.swagger.v3.oas.annotations.media does not exist
Additional (required, it seems?) dependencies for plugin are not listed in docs, so I believe it's a bug.

openapi-generator version

7.0.1 maven plugin

OpenAPI declaration file content or url

https://gist.github.com/Haarolean/8a9b07f74544c7e45d553ff33798ed8c (swagger petstore)

Generation Details

maven,

    <build>
        <plugins>
            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>7.0.1</version>
                <executions>
                    <execution>
                        <id>interfaces</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
                            <output>${project.build.directory}/generated-sources/api</output>
                            <generatorName>spring</generatorName>
                            <modelNameSuffix>DTO</modelNameSuffix>
                            <configOptions>
                                <modelPackage>lol.memelord.kapybro.api.dto</modelPackage>
                                <apiPackage>lol.memelord.kapybro.api.api</apiPackage>
                                <sourceFolder>test</sourceFolder>
                                <interfaceOnly>true</interfaceOnly>
                                <skipDefaultInterface>true</skipDefaultInterface>
                                <useBeanValidation>true</useBeanValidation>
                                <useTags>true</useTags>
                                <useSpringBoot3>true</useSpringBoot3>
                                <dateLibrary>java8</dateLibrary>
<!--                                <useOpenApiNullable>false</useOpenApiNullable>-->
<!--                                <openApiNullable>false</openApiNullable>-->
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
Steps to reproduce
  1. Build the spec
Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Maven plugin configuration against the linked Swagger Petstore spec and inspect the generated api/dto/ApiResponseDTO.java error. Read the Maven plugin documentation and compare its documented dependencies with the generated Spring Boot 3 example. Done means the example builds successfully and the required dependency or setup is accurately documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
backend-api-design, build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.