Пример #1
0
        protected override OpenApiSchema GenerateSchemaFor(ModelMetadata modelMetadata, SchemaRepository schemaRepository, JsonContract jsonContract)
        {
            if (!schemaRepository.TryGetIdFor(modelMetadata.ModelType, out string schemaId))
            {
                schemaId = SchemaGeneratorOptions.SchemaIdSelector(modelMetadata.ModelType);
                schemaRepository.ReserveIdFor(modelMetadata.ModelType, schemaId);

                schemaRepository.AddSchemaFor(modelMetadata.ModelType, Next.GenerateSchema(modelMetadata, schemaRepository, jsonContract));
            }

            return(new OpenApiSchema
            {
                Reference = new OpenApiReference {
                    Id = schemaId, Type = ReferenceType.Schema
                }
            });
        }
Пример #2
0
        protected override OpenApiSchema GenerateSchemaFor(Type type, SchemaRepository schemaRepository)
        {
            if (!schemaRepository.TryGetIdFor(type, out string schemaId))
            {
                schemaId = Options.SchemaIdSelector(type);
                schemaRepository.ReserveIdFor(type, schemaId);

                schemaRepository.AddSchemaFor(type, Next.GenerateSchema(type, schemaRepository));
            }

            return(new OpenApiSchema
            {
                Reference = new OpenApiReference {
                    Id = schemaId, Type = ReferenceType.Schema
                }
            });
        }
        private OpenApiSchema GenerateReferenceSchemaFor(Type type, SchemaRepository schemaRepository, JsonContract jsonContract)
        {
            if (!schemaRepository.TryGetIdFor(type, out string schemaId))
            {
                schemaId = _options.SchemaIdSelector(type);
                schemaRepository.ReserveIdFor(type, schemaId);

                schemaRepository.AddSchemaFor(type, GenerateDefinitionSchemaFor(type, schemaRepository, jsonContract));
            }

            return(new OpenApiSchema
            {
                Reference = new OpenApiReference {
                    Id = schemaId, Type = ReferenceType.Schema
                }
            });
        }