Skip to content

Commit

Permalink
Support x-go-name for top level schemas
Browse files Browse the repository at this point in the history
This fixes oapi-codegen#583. Add support for x-go-name to Schemas, Parameters,
Responses, and RequestBodies. This means we also need to have spec-aware
refPath resolution, so I refactored that a bit.

The x-go-name is not post-processed and is assumed to be a valid
Go identifier.
  • Loading branch information
marcinromaszewicz committed May 21, 2022
1 parent 8e67052 commit f0d9841
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 162 deletions.
134 changes: 18 additions & 116 deletions internal/test/components/components.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions internal/test/components/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,26 @@ components:
- '5'
- '&'
- ''
RenameMe:
description: This schema should be renamed via x-go-name when generating
x-go-name: NewName
type: object
properties:
prop1:
type: string
prop2:
type: string
required: [prop1, prop2]
ReferenceToRenameMe:
description: When a Schema is renamed, $ref should refer to the new name
type: object
properties:
ToNewName:
$ref: "#/components/schemas/RenameMe"
required: [ToNewName]
responses:
ResponseObject:
x-go-name: RenamedResponseObject
description: A simple response object
content:
application/json:
Expand All @@ -247,6 +265,7 @@ components:
type: string
parameters:
ParameterObject:
x-go-name: RenamedParameterObject
name: ParameterObject
description: a parameter
in: query
Expand Down Expand Up @@ -283,6 +302,7 @@ components:
enum: [ alice, eve, bob ]
requestBodies:
RequestBody:
x-go-name: RenamedRequestBody
content:
application/json:
schema:
Expand Down
1 change: 0 additions & 1 deletion internal/test/components/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ package: components
generate:
- types
- skip-prune
- spec

0 comments on commit f0d9841

Please sign in to comment.