Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
NSwag Typescript Proxy custom property annotations/decorators

I am using NSwag.CodeGeneration.Typescript to generate an angular 2 typescript proxy from a .net-core backend and the swagger.json. This works like a charm.

Now I would like to be able to automatically generate custom decorators for my typescript client. Something like this:

The C# class:

public class Point {
   // a configurable annotation here
   [configurable]
   private int X
   {
      get; set;
   }
   // a configurable annotation here
   [configurable]
   private int Y
   {
      get; set;
   }        
}

The generated typescript proxy...

class Point {
private _x: number;
private _y: number;
constructor(data?: any) {
    // set data
}

@configurable(false)
get x() { return this._x; }

@configurable(false)
get y() { return this._y; }
}

...with the custom decorator function

function configurable(value: boolean) {
    return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
        descriptor.configurable = value;
    };
}

It's my first project with swagger, so I'm not entirely sure where to start. Any help is greatly appreciated.

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda