Last active
July 2, 2024 13:10
-
-
Save RonnyPfannschmidt/8a852d04df4a786adf79156b4b265ae8 to your computer and use it in GitHub Desktop.
openapi spec - show distinct needed tpyes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.0 | |
info: | |
title: Pet Store Service | |
description: This is a sample server Petstore server. | |
version: 0.0.0 | |
tags: [] | |
paths: | |
/: | |
post: | |
operationId: Ratings_create | |
parameters: [] | |
responses: | |
'200': | |
description: The request has succeeded. | |
requestBody: | |
required: true | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/NamedRating' | |
/{id}: | |
post: | |
operationId: Ratings_update | |
parameters: | |
- name: id | |
in: path | |
required: true | |
schema: | |
type: integer | |
responses: | |
'200': | |
description: The request has succeeded. | |
requestBody: | |
required: true | |
content: | |
application/json: | |
schema: | |
anyOf: | |
- $ref: '#/components/schemas/NamedRating' | |
- $ref: '#/components/schemas/PatchRatingNumber' | |
components: | |
schemas: | |
NamedRating: | |
type: object | |
required: | |
- name | |
properties: | |
name: | |
type: string | |
rating: | |
type: integer | |
description: may be left out | |
PatchRatingNumber: | |
type: object | |
required: | |
- rating | |
properties: | |
rating: | |
type: integer | |
nullable: true | |
description: this one needs a value | |
servers: | |
- url: https://example.com | |
description: Single server endpoint | |
variables: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@typespec/http"; | |
import "@typespec/rest"; | |
using TypeSpec.Http; | |
using TypeSpec.Rest; | |
/** | |
* This is a sample server Petstore server. | |
*/ | |
@service({ | |
title: "Pet Store Service", | |
}) | |
@server("https://example.com", "Single server endpoint") | |
namespace Ratings; | |
model NamedRating { | |
name: string; | |
@doc("may be left out") | |
rating?: integer; | |
} | |
model PatchRatingNumber { | |
@doc("this one needs a value") | |
rating: integer | null; | |
} | |
interface Ratings { | |
op create(@body rating: NamedRating): {}; | |
@route("/{id}") | |
@post | |
op update(id: integer, @body update: NamedRating|PatchRatingNumber): {}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment