-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Description
When I try to run the below spec, I receive warnings that creates bad codes. I don't understand what is the problem since my spec is valid in every validator I tried. I'm pretty sure it's related to the fact that the code is now generated with real inheritance, which was not the case in swagger-codegen (I think it was using composition only).
In the code, it will generate something like this for example:
DefaultMetaOnlyResponse logout(Object UNKNOWN_BASE_TYPE) throws Exception;
Here is the complete warning:
[main] WARN org.openapitools.codegen.DefaultCodegen - The folowing schema has undefined (null) baseType. It could be due to form parameter defined in OpenAPI v2 spec with incorrect consumes. A correct 'consumes' for form parameters should be 'application/x-www-form-urlencoded' or 'multipart/form-data'
[main] WARN org.openapitools.codegen.DefaultCodegen - schema: class ObjectSchema {
class Schema {
title: null
multipleOf: null
maximum: null
exclusiveMaximum: null
minimum: null
exclusiveMinimum: null
maxLength: null
minLength: null
pattern: null
maxItems: null
minItems: null
uniqueItems: null
maxProperties: null
minProperties: null
required: null
type: null
not: null
properties: null
additionalProperties: null
description: Empty object used for POST or PUT that doesn't shouldn't have body but need one to pass play framework validation
format: null
$ref: null
nullable: null
readOnly: null
writeOnly: null
example: null
externalDocs: null
deprecated: null
discriminator: null
xml: null
}
type: object
defaultObject: null
}
[main] WARN org.openapitools.codegen.DefaultCodegen - Defaulting baseType to UNKNOWN_BASE_TYPE
openapi-generator version
Master (3.0.0) updated to the latest commit
OpenAPI declaration file content or url
This is a 2 files spec:
swagger.yaml
swagger: '2.0'
info:
version: "1.0.1"
title: Control Site REST API
description: blablabla
termsOfService: www
basePath: /api
host: "http://localhost:9000"
consumes:
- application/json
produces:
- application/json
################################################################################
# Parameters #
################################################################################
parameters:
empty-body:
in: body
name: empty-body
required: true
schema:
$ref: "./definitions.yaml#/definitions/EmptyObject"
################################################################################
# EndPoints #
################################################################################
paths:
/something:
put:
tags:
- Foo
summary: Update something
operationId: update something
parameters:
- $ref: "#/parameters/empty-body"
responses:
200:
description: OK
schema:
$ref: "./definitions.yaml#/definitions/DefaultMetaOnlyResponse"definitions.yaml
definitions:
EmptyObject:
type: object
description: "Empty object used for POST or PUT that doesn't shouldn't have body but need one to pass play framework validation"
ResponseMeta:
type: object
description: "Mandatory part of each response given by our API"
required:
- code
properties:
code:
type: string
description: "Code returned by the function"
default: Ok
enum:
- Ok
example: Ok
################ Responses ##################
DefaultMetaOnlyResponse:
type: object
required:
- meta
properties:
meta:
$ref: "#/definitions/ResponseMeta"Command line used for generation
java -jar openapi-generator-cli.jar generate -i ../public/swagger.yaml --generator-name
java-play-framework -o generatedServer -DhideGenerationTimestamp=true
Steps to reproduce
Run the above command line with the spec and you will see the warning.
Related issues/PRs
Nothing that I know of
Suggest a fix/enhancement
I think it's related to the object EmptyObject which is used by the parameter empty-body. The warning is talking about "form" but as you can see, it is used with a body, not a form.