[Protobuf] Fix how map is generated (#8203)

* test map with protobuf

* fix protobuf map

* use unescaped value

* use string

* undo changes to spec
This commit is contained in:
William Cheng
2020-12-16 15:33:41 +08:00
committed by GitHub
parent a4f84b2f8c
commit afa750f249
2 changed files with 2 additions and 2 deletions

View File

@@ -490,7 +490,7 @@ public class ProtobufSchemaCodegen extends DefaultCodegen implements CodegenConf
return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]";
} else if (ModelUtils.isMapSchema(p)) {
Schema inner = getAdditionalProperties(p);
return getSchemaType(p) + "[str, " + getTypeDeclaration(inner) + "]";
return getSchemaType(p) + "<string, " + getTypeDeclaration(inner) + ">";
}
return super.getTypeDeclaration(p);
}

View File

@@ -18,7 +18,7 @@ message {{classname}} {
// {{{.}}}
{{/description}}
{{^isEnum}}
{{#vendorExtensions.x-protobuf-type}}{{.}} {{/vendorExtensions.x-protobuf-type}}{{vendorExtensions.x-protobuf-data-type}} {{name}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}};
{{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{{name}}} = {{vendorExtensions.x-protobuf-index}}{{#vendorExtensions.x-protobuf-packed}} [packed=true]{{/vendorExtensions.x-protobuf-packed}};
{{/isEnum}}
{{#isEnum}}
enum {{enumName}} {