Skip to content
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
65 changes: 65 additions & 0 deletions src/OpenApi/sample/Endpoints/MapSchemasEndoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,72 @@ public static IEndpointRouteBuilder MapSchemasEndpoints(this IEndpointRouteBuild
schemas.MapPost("/shape", (Shape shape) => { });
schemas.MapPost("/weatherforecastbase", (WeatherForecastBase forecast) => { });
schemas.MapPost("/person", (Person person) => { });
schemas.MapPost("/category", (Category category) => { });
schemas.MapPost("/container", (ContainerType container) => { });
schemas.MapPost("/root", (Root root) => { });
schemas.MapPost("/location", (LocationContainer location) => { });
schemas.MapPost("/parent", (ParentObject parent) => Results.Ok(parent));
schemas.MapPost("/child", (ChildObject child) => Results.Ok(child));

return endpointRouteBuilder;
}

public sealed class Category
{
public required string Name { get; set; }

public required Category Parent { get; set; }

public IEnumerable<Tag> Tags { get; set; } = [];
}

public sealed class Tag
{
public required string Name { get; set; }
}

public sealed class ContainerType
{
public List<List<string>> Seq1 { get; set; } = [];
public List<List<string>> Seq2 { get; set; } = [];
}

public sealed class Root
{
public Item Item1 { get; set; } = null!;
public Item Item2 { get; set; } = null!;
}

public sealed class Item
{
public string[] Name { get; set; } = null!;
public int value { get; set; }
}

public sealed class LocationContainer
{
public required LocationDto Location { get; set; }
}

public sealed class LocationDto
{
public required AddressDto Address { get; set; }
}

public sealed class AddressDto
{
public required LocationDto RelatedLocation { get; set; }
}

public sealed class ParentObject
{
public int Id { get; set; }
public List<ChildObject> Children { get; set; } = [];
}

public sealed class ChildObject
{
public int Id { get; set; }
public required ParentObject Parent { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,138 @@
}
}
}
},
"/schemas-by-ref/category": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Category"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/schemas-by-ref/container": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ContainerType"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/schemas-by-ref/root": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Root"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/schemas-by-ref/location": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LocationContainer"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/schemas-by-ref/parent": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ParentObject"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/schemas-by-ref/child": {
"post": {
"tags": [
"Sample"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChildObject"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK"
}
}
}
}
},
"components": {
Expand All @@ -391,6 +523,113 @@
}
}
},
"AddressDto": {
"required": [
"relatedLocation"
],
"type": "object",
"properties": {
"relatedLocation": {
"$ref": "#/components/schemas/LocationDto"
}
}
},
"Category": {
"required": [
"name",
"parent"
],
"type": "object",
"properties": {
"name": {
"type": "string"
},
"parent": {
"$ref": "#/components/schemas/Category"
},
"tags": { }
}
},
"ChildObject": {
"required": [
"parent"
],
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"parent": {
"$ref": "#/components/schemas/ParentObject"
}
}
},
"ContainerType": {
"type": "object",
"properties": {
"seq1": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "string"
}
}
},
"seq2": {
"type": "array",
"items": { }
}
}
},
"Item": {
"type": "object",
"properties": {
"name": { },
"value": {
"type": "integer",
"format": "int32"
}
}
},
"LocationContainer": {
"required": [
"location"
],
"type": "object",
"properties": {
"location": {
"$ref": "#/components/schemas/LocationDto"
}
}
},
"LocationDto": {
"required": [
"address"
],
"type": "object",
"properties": {
"address": {
"$ref": "#/components/schemas/AddressDto"
}
}
},
"ParentObject": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"children": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ChildObject"
}
}
}
},
"Person": {
"required": [
"discriminator"
Expand Down Expand Up @@ -454,6 +693,17 @@
}
}
},
"Root": {
"type": "object",
"properties": {
"item1": {
"$ref": "#/components/schemas/Item"
},
"item2": {
"$ref": "#/components/schemas/Item"
}
}
},
"Shape": {
"required": [
"$type"
Expand Down Expand Up @@ -517,6 +767,17 @@
}
}
},
"Tag": {
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"Triangle": {
"type": "object",
"properties": {
Expand Down
Loading
Loading