Reputation: 347
i'm trying to use swagger-codegen-maven-plugin to generate my interface . after compiling with the plugin - it generates all the files correctly but for some reason the interface name is DefaultApi.
i looked for some configuration that i can change the name of the interface that been generated but didnt find the solution for that.
any idea on that??
Upvotes: 20
Views: 14771
Reputation: 776
Side note for <useTags>true<useTags>
, you need to specify tags both for root of your specs file and for each endpoint you have in your file.
openapi: 3.0.3
info:
title:
version: "1.0"
description:
tags:
- name: myApi
servers:
- url: http://localhost:8080
paths:
/thisPathWontAffectTheGeneratedClassNames
get:
operationId:
description:
tags:
- myTag
...
Resulting API: MyTagApi
Upvotes: 0
Reputation: 10807
"DefaultApi" is used when there's no tags
specified for the endpoint.
For example, this endpoint will be put in a class named "UserApi" since the tags
is set to User
.
You will need to update the spec to include proper tags
for endpoints to avoid using "DefaultApi"
UPDATE: On May 2018, about 50 top contributors and template creators of Swagger Codegen decided to fork Swagger Codegen to maintain a community-driven version called OpenAPI Generator. Please refer to the Q&A for more information.
Starting in OpenAPI Generator v7.0.0, one can use openapi-normalizer with the rule SET_TAGS_FOR_ALL_OPERATIONS
to force all operations using a particular tag.
Upvotes: 24