additionalProperties for object produces empty fields
master
3.1.x
swagger: "2.0"
info:
description: app
version: 1.0.0
title: Application
host: localhost:32000
basePath: /api/v1.0
schemes:
- http
tags:
- name: ApplicationResources
x-displayName: "ApplicationResources"
description: |
"Resources managed by the application instance."
paths:
/default/ApiTestSetup:
get:
description: "Test Setup"
operationId: apiTestConfigurationGet
responses:
200:
description: "Successful response"
schema:
$ref: "#/definitions/TestEndPointConfig"
400:
description: "The request was not successfully executed."
definitions:
TestEndPointConfig :
type : "object"
additionalProperties :
type: "string"
Code Produced
type TestEndPointConfig struct {
}
java -jar /home/dev/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./app.yaml -o ./gengo-server -l go-server --additional-properties packageName=app --additional-properties hideGenerationTimestamp=true
I did another test with #1296 and no longer got the empty struct:
➜ openapi-generator git:(skip_map_model) java -jar "./modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate -i /var/tmp/regression.yaml -g go -o /tmp/go3/
[main] WARN o.o.c.ignore.CodegenIgnoreProcessor - Output directory does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO o.o.c.languages.AbstractGoCodegen - Environment variable GO_POST_PROCESS_FILE not defined so Go code may not be properly formatted. To define it, try `export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"` (Linux/Mac)
[main] INFO o.o.c.languages.AbstractGoCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO o.o.codegen.DefaultGenerator - Model TestEndPointConfig not generated since it's an alias to map (without property)
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/api_default.go
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/docs/DefaultApi.md
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/api/openapi.yaml
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/README.md
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/git_push.sh
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/.gitignore
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/configuration.go
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/client.go
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/response.go
[main] INFO o.o.codegen.DefaultGenerator - writing file /tmp/go3/.travis.yml
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/.openapi-generator-ignore
[main] INFO o.o.codegen.AbstractGenerator - writing file /tmp/go3/.openapi-generator/VERSION
Nice.
go get -d .
go build .
/test/gengo
./api_default.go:89:10: undefined: TestEndPointConfig
if localVarHttpResponse.StatusCode == 200 {
var v TestEndPointConfig
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
Failed :(
I think the model reference should be unaliased in the response too.
Let me look into it...
Just pushed an update and I now get this:
if localVarHttpResponse.StatusCode == 200 {
var v map[string]string
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
I compiled it successfully.