Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ir): do not panic, if generating postfix for Any type #187

Merged
merged 1 commit into from
Feb 14, 2022
Merged
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
177 changes: 177 additions & 0 deletions _testdata/positive/pokemon-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"info": {
"license": {
"name": "Not specified"
},
"title": "Not specified",
"version": "Not specified"
},
"openapi": "3.0.3",
"paths": {
"/pokemonByName": {
"get": {
"parameters": [
{
"in": "query",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"properties": {
"pokemon": {
"nullable": true,
"properties": {
"attacks": {
"description": "The attacks of this Pokémon",
"nullable": true,
"properties": {
"special": {
"description": "The special attacks of this Pokémon",
"items": {
"properties": {
"damage": {
"description": "The damage of this Pokémon attack",
"nullable": true,
"type": "integer"
},
"name": {
"description": "The name of this Pokémon attack",
"nullable": true,
"type": "string"
},
"type": {
"description": "The type of this Pokémon attack",
"nullable": true,
"type": "string"
}
},
"type": "object"
},
"nullable": true,
"type": "array"
}
},
"type": "object"
},
"evolutions": {
"description": "The evolutions of this Pokémon",
"items": {
"properties": {
"attacks": {
"description": "The attacks of this Pokémon",
"nullable": true,
"properties": {
"fast": {
"description": "The fast attacks of this Pokémon",
"items": {
"properties": {
"damage": {
"description": "The damage of this Pokémon attack",
"nullable": true,
"type": "integer"
},
"name": {
"description": "The name of this Pokémon attack",
"nullable": true,
"type": "string"
},
"type": {
"description": "The type of this Pokémon attack",
"nullable": true,
"type": "string"
}
},
"type": "object"
},
"nullable": true,
"type": "array"
}
},
"type": "object"
},
"id": {
"description": "The ID of an object",
"nullable": false,
"type": "string"
},
"name": {
"description": "The name of this Pokémon",
"nullable": true,
"type": "string"
},
"number": {
"description": "The identifier of this Pokémon",
"nullable": true,
"type": "string"
},
"weight": {
"description": "The minimum and maximum weight of this Pokémon",
"nullable": true,
"properties": {
"maximum": {
"description": "The maximum value of this dimension",
"nullable": true,
"type": "string"
},
"minimum": {
"description": "The minimum value of this dimension",
"nullable": true,
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"nullable": true,
"type": "array"
},
"locations": {
"description": "Locations Pokémon lives",
"nullable": true,
"type": "array"
},
"name": {
"description": "The name of this Pokémon",
"nullable": true,
"type": "string"
},
"number": {
"description": "The identifier of this Pokémon",
"nullable": true,
"type": "string"
},
"pokemonId": {
"description": "The ID of an object",
"nullable": false,
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
}
},
"description": "response"
}
}
}
}
},
"servers": [
{
"url": "/"
}
]
}
3 changes: 2 additions & 1 deletion internal/ir/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,13 @@ func (t *Type) NamePostfix() string {
}
case KindArray:
return t.Item.NamePostfix() + "Array"
case KindAny:
return "Any"
case KindPointer:
return t.PointerTo.NamePostfix() + "Pointer"
case KindStruct, KindMap, KindAlias, KindInterface, KindGeneric, KindEnum, KindSum, KindStream:
return t.Name
default:
// KindAny and KindPointer must not be wrapped.
panic(fmt.Sprintf("unexpected kind: %s", t.Kind))
}
}