Skip to content

Commit

Permalink
Honor @json annotation in OpenAPI generator
Browse files Browse the repository at this point in the history
Currently the OpenAPI specification generator doesn't honor the `@json`
annotation. This patch fixes that.

Signed-off-by: Juan Hernandez <[email protected]>
  • Loading branch information
jhernand committed May 18, 2023
1 parent 6563424 commit 8b562cb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/generators/openapi/names_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"path/filepath"

"github.com/openshift-online/ocm-api-metamodel/pkg/annotations"
"github.com/openshift-online/ocm-api-metamodel/pkg/concepts"
"github.com/openshift-online/ocm-api-metamodel/pkg/reporter"
)
Expand Down Expand Up @@ -80,7 +81,11 @@ func (c *NamesCalculator) SchemaName(typ *concepts.Type) string {

// AttributePropertyName calculates the property name for an attribute of a struct type.
func (c *NamesCalculator) AttributePropertyName(attribute *concepts.Attribute) string {
return attribute.Name().Snake()
name := annotations.JSONName(attribute)
if name == "" {
name = attribute.Name().Snake()
}
return name
}

// ParameterPropertyName calculates the property name for an parameter of a method.
Expand Down

0 comments on commit 8b562cb

Please sign in to comment.