Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public MappedModel(String mappingName, String modelName, boolean explicitMapping
this.explicitMapping = explicitMapping;
}

public boolean isExplicitMapping() {
return explicitMapping;
}

public MappedModel(String mappingName, String modelName) {
this(mappingName, modelName, false);
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
enum {{classname}} {
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{protobuf-enum-index}}};
{{/enumVars}}
{{/allowableValues}}
{{!
Generates an extracted enum wrapped in a message container.

This wrapper pattern is used to prevent enum value name collisions
in the Protocol Buffers global enum namespace. Multiple enums can
have values with the same name when wrapped in separate messages.

Generated format:
message EnumName {
enum Enum {
VALUE1 = 0;
VALUE2 = 1;
}
}

Usage in models: EnumName.Enum field_name = 1;
}}
message {{classname}} {
enum Enum {
{{#allowableValues}}
{{#enumVars}}
{{{name}}} = {{{protobuf-enum-index}}};
{{/enumVars}}
{{/allowableValues}}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import public "{{{.}}}.proto";
{{#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-json-name}} [json_name="{{vendorExtensions.x-protobuf-json-name}}"]{{/vendorExtensions.x-protobuf-json-name}};
{{/isEnum}}
{{#isEnum}}
{{^vendorExtensions.x-protobuf-enum-reference-import}}
enum {{enumName}} {
{{#allowableValues}}
{{#enumVars}}
Expand All @@ -45,7 +46,8 @@ import public "{{{.}}}.proto";
{{/allowableValues}}
}

{{enumName}} {{name}} = {{vendorExtensions.x-protobuf-index}};
{{/vendorExtensions.x-protobuf-enum-reference-import}}
{{#vendorExtensions.x-protobuf-type}}{{{.}}} {{/vendorExtensions.x-protobuf-type}}{{{vendorExtensions.x-protobuf-data-type}}} {{name}} = {{vendorExtensions.x-protobuf-index}};
{{/isEnum}}

{{/vars}}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ components:
properties:
name:
type: string
characteristics:
$ref: '#/components/schemas/Characteristics'
Reptile:
allOf:
- $ref: '#/components/schemas/Pet'
Expand Down Expand Up @@ -78,7 +80,7 @@ components:
- $ref: '#/components/schemas/Lizard'
discriminator:
propertyName: petType
# per https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminatorObject
# per https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#discriminator-object
# this discriminator must be included to use it as a hint to pick a schema
MyPetsNoDisc:
oneOf:
Expand All @@ -101,3 +103,8 @@ components:
C:
allOf:
- $ref: '#/components/schemas/B'
Characteristics:
type: object
properties:
canHunt:
type: boolean
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
openapi: 3.0.3
info:
title: OAI Specification example for Polymorphism
version: 1.0.0
paths:
/status:
get:
responses:
'201':
description: desc

components:
schemas:
Animal:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
mapping:
dog: '#/components/schemas/Dog'
cat: '#/components/schemas/Cat'
Feline:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
name:
type: string
furColor:
type: string
Cat:
allOf:
- $ref: '#/components/schemas/Feline'
- type: object
properties:
isIndoor:
type: boolean
careDetails:
$ref: '#/components/schemas/CareDetails'
Dog:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
bark:
type: string
CareDetails:
type: object
properties:
veterinarian:
type: string
lastVetVisit:
type: string
format: date
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
OAI Specification example for Polymorphism

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

The version of the OpenAPI document: 1.0.0

Generated by OpenAPI Generator: https://openapi-generator.tech
*/

syntax = "proto3";

package openapitools;

import public "models/care_details.proto";

message Animal {

string pet_type = 482112090;

string name = 3373707;

string fur_color = 478695002;

bool is_indoor = 183319801;

CareDetails care_details = 176721135;

string bark = 3016376;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
openapi: 3.0.0
info:
title: Enum extraction test
version: '2.0'
paths: {}
components:
schemas:
SeparatedEnum:
type: string
enum:
- VALUE1
- VALUE2
ModelWithEnums:
type: object
properties:
referenceEnumProperty:
$ref: "#/components/schemas/SeparatedEnum"
inlineEnumProperty:
type: string
enum:
- VALUE2
- VALUE3
- VALUE4
listOfEnums:
type: array
items:
type: string
enum:
- VALUE10
- VALUE11
AllOfModelWithEnums:
allOf:
- $ref: "#/components/schemas/ModelWithEnums"
- type: object
properties:
anotherInlineEnumProperty:
type: string
enum:
- VALUE5
- VALUE6
listOfReferencedEnums:
type: array
items:
$ref: '#/components/schemas/SeparatedEnum'
DiscriminatedModel:
type: object
properties:
commonProperty:
type: string
modelType:
type: string
discriminator:
propertyName: modelType
mapping:
typeA: "#/components/schemas/ModelTypeAWithInlineEnum"
typeB: "#/components/schemas/ModelTypeBWithInlineEnum"
ModelTypeAWithInlineEnum:
allOf:
- $ref: "#/components/schemas/DiscriminatedModel"
- type: object
properties:
specificPropertyA:
type: string
inlineEnumProperty:
type: string
enum:
- VALUE7
- VALUE8
ModelTypeBWithInlineEnum:
allOf:
- $ref: "#/components/schemas/DiscriminatedModel"
- type: object
properties:
specificPropertyB:
type: string
referenceEnumPropertyB:
$ref: "#/components/schemas/SeparatedEnum"
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
openapi: 3.0.0
info:
title: Model Import Test
version: 1.0.0
paths: {}
components:
schemas:
A:
type: object
description: Base model A that will be referenced multiple times
properties:
id:
type: string
value:
type: string
required:
- id

SubModel:
type: object
description: SubModel that uses model A
allOf:
- $ref: '#/components/schemas/ExtensibleModel'
- type: object
properties:
subField:
type: string
aReference:
$ref: '#/components/schemas/A'
required:
- subField

Model:
type: object
description: Main model that uses A directly and via SubModel
properties:
name:
type: string
directA:
$ref: '#/components/schemas/A'
nestedSubModel:
$ref: '#/components/schemas/SubModel'
required:
- name

ExtensibleModel:
type: object
description: Extensible model with discriminator that uses model A
discriminator:
propertyName: type
mapping:
child1: '#/components/schemas/ChildModel_1'
child2: '#/components/schemas/ChildModel_2'
properties:
type:
type: string
extensibleA:
$ref: '#/components/schemas/A'
required:
- type

ChildModel_1:
allOf:
- $ref: '#/components/schemas/ExtensibleModel'
- type: object
properties:
childSpecificField:
type: string
childA:
$ref: '#/components/schemas/A'
ChildModel_2:
allOf:
- $ref: '#/components/schemas/SubExtensibleModel'
- type: object
properties:
anotherChildSpecificField:
type: integer
directA:
$ref: '#/components/schemas/A'

SubExtensibleModel:
allOf:
- $ref: '#/components/schemas/ExtensibleModel'
- type: object
properties:
aSubExtensibleField:
type: boolean
subDirectA:
$ref: '#/components/schemas/A'
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ syntax = "proto3";

package openapitools;

import public "models/characteristics.proto";
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Imported proto file models/characteristics.proto is missing, leaving Characteristics unresolved and making the schema uncompilable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/test/resources/3_0/protobuf-schema/pet.proto, line 15:

<comment>Imported proto file `models/characteristics.proto` is missing, leaving `Characteristics` unresolved and making the schema uncompilable.</comment>

<file context>
@@ -12,14 +12,20 @@ syntax = "proto3";
 
 package openapitools;
 
+import public "models/characteristics.proto";
+
 message Pet {
</file context>
Fix with Cubic


message Pet {

string pet_type = 482112090;

string name = 3373707;

Characteristics characteristics = 455429578;

string bark = 3016376;

bool loves_rocks = 465093427;

bool has_legs = 140596906;

}