Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add support for OpenAPI schema generation for POCOs #1087

Copy link
Copy link
@captainsafia

Description

@captainsafia
Issue body actions

This is related to #836.

For certain native .NET types, it would be great if OpenAPI.NET could provide the authorative OpenApiSchema definitions for these types. Current prototypes maintain a dictionary like this:

private static readonly Dictionary<Type, Func<OpenApiSchema>> _primitiveTypeToOpenApiSchema =
        new()
        {
            [typeof(bool)] = () => new OpenApiSchema { Type = "boolean" },
            [typeof(byte)] = () => new OpenApiSchema { Type = "string", Format = "byte" },
            [typeof(int)] = () => new OpenApiSchema { Type = "integer", Format = "int32" },
            ...
            [typeof(DateTime)] = () => new OpenApiSchema { Type = "string", Format = "date-time" },
            [typeof(DateTimeOffset)] = () => new OpenApiSchema { Type = "string", Format = "date-time" },
            [typeof(Guid)] = () => new OpenApiSchema { Type = "string", Format = "uuid" },
            [typeof(char)] = () => new OpenApiSchema { Type = "string" }
        };

And there a variety of open source packages/projects that maintain their own associations (see this, this, and this).

Since this is a finite set of mappings, it would be great if they would be centralized in the OpenAPI.NET package to avoid duplication and ambiguity about the right schemas to generate for different native types in .NET.

cc: @darrelmiller @baywet

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

goodfirstissueStandard GitHub label used for easy to resolve issues targeting beginner contributorsStandard GitHub label used for easy to resolve issues targeting beginner contributorstype:enhancementEnhancement request targeting an existing experienceEnhancement request targeting an existing experience

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.