|
We see a whole load of posts about how Microsoft sucks. Well, this is praise for them. In my day to day, I do a load of API design work using OpenAPI. Frankly, while OpenAPI is great, the tooling and development of it is less than amazing. It's cumbersome, and it doesn't promote easy reuse. Well, Microsoft has produced something called TypeSpec[^] which makes API design an absolute delight. It's now supplanting my tool of choice (SwaggerHub). So, I want my APIs to return all records on an endpoint and I want them to have common statuses on the return. Well, if I do this:
op all<T>(): {
@statusCode statusCode: 200;
@body records: T[];
} | {
@statusCode statusCode: 400;
@body error: Error;
} | {
@statusCode statusCode: 401;
} | {
@statusCode statusCode: 403;
}; Then I can do this:
@route("/organizations")
interface Organizations {
op all is all<Organization>;
} Well, what does that look like when I produce my OpenAPI design out of this?
openapi: 3.0.0
info:
title: Some title
version: 0.0.0
tags: []
paths:
/organizations:
get:
operationId: Organizations_all
parameters: []
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
type: array
items:
$ref: '
'400':
description: The server could not understand the request due to invalid syntax.
content:
application/json:
schema:
$ref: '
'401':
description: Access is unauthorized.
'403':
description: Access is forbidden
components:
schemas:
Organization:
type: object
required:
- id
- name
- apiKey
properties:
id:
type: string
format: uuid
description: The unique identifier for the organisation
name:
type: string
description: The name of the organisation
servers:
- url: https://api.my.services
description: Single Endpoint
variables: {} All in all, that's pretty darn awesome and it allows me to produce consistent API responses with the minimum of fuss.
|
|
|
|
|
In my case, most of my posts against Microsoft are mostly in the insider news and more in joke, sacarsm mode than real rants.
At the end of the day I am still using it and will still use it (at least at job)
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
https://www.charachorder.com/products/charachorder-one[^]
synopsis : a uniquely shaped keyboard permitting "chords" i.e. simultaneous key strokes also w/ minimum finger movement i.e. each key has four associated characters via joy-stick like motion North South East West. also other product converting conventional keyboard to chording.
|
|
|
|
|
It was hard enough/took long enough for me to learn how to type the first time around. I'd rather not have to repeat it.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
50% of the time, this is a nice feature.
The other 50%, I hate it as I have to clean up the BS it adds. Like
using static System.Runtime.InteropServices.JavaScript.JSType;
using System.Runtime.Intrinsics.X86;
using System.Security.Policy;
using Twilio.TwiML.Voice; Seriously? Where does it think I need those??? And yes, I know I can turn this off, somewhere, but the 50% when I like it, I want it.
|
|
|
|
|
It shouldn't do it when it has to autocomplete the referenced item. For example, if it autocompletes ThreadPool but you didn't type it it shouldn't add the using System.Threading.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
What language?
I just delete them all.
I use the using directive only for aliases and for adding Extension Methods.
|
|
|
|
|
There is also a setting that allows it to remove unused ones on build. Might keep you from manually deleting them.
HTH
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Personally, I can't use that one either without extra configuration work.
The reason being is I often target the dotnet framework as well as the newer dotnet offerings, and the newer ones have things like System.Collections.Generic already implicitly declared. Sharing the source file between each would cause an error in the DNF version if the newer dotnet version of the project gets built.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I'm not even sure if this is a programming question, a networking question, a Windows question...
I'm completely at a loss of where to look!
I'm developing a web app with a service in ASP.NET 8, both need a subdomain.
So I have sub.localhost:1234 for the web app and sub.localhost:5678 for the service.
I can access both in my browser, but my web app can't access the service ("no such host is known").
When I'm at home, it works.
When I'm at home and on VPN it doesn't work.
It works with and without VPN for my coworker, but only from home.
At the office, it doesn't work with or without VPN for both of us.
At first I though the VPN was the problem because at home it worked without the VPN, but today I'm at the office and it doesn't work at all (even though I developed this service at the office!).
We've deployed both in an Azure app service with the subdomain properly registered in the DNS and a valid certificate.
The web app can't access the service, again because "no such host is known".
We can, however, access the service in Azure from our development environment (sub.localhost:1234), but for me only without VPN and for my coworker only with VPN and only from home.
We can access the service from its Azure domain (e.g. myservice.azurewebsites.net).
The plot thickens, because for my coworker one specific controller does seem to work at the office, but not from home (it doesn't work for me at all).
The controller isn't particularly interesting.
When I remove the subdomain everything works.
It seems completely random and I can't even think of where to look...
At least I can rule out it's not a firewall issue (turned it off completely with no result).
Has anyone seen this before or have a clue of where to look?
|
|
|
|
|
sub.localhost makes no sense to me at all.
If we are saying localhost, it's a given that everything is at 127.0.0.1.
Maybe there is some reason you need *different* domains though for local app<->service.
In that case, I would ditch sub.localhost and go with something more akin:
myappservice 127.0.0.1
myapp 127.0.0.1
added to %windir%/system/drivers/etc/hosts
|
|
|
|
|
The sub domain is any customer location code.
So it's loc1.localhost or loc2.localhost.
I've thought about the hosts file, but that won't explain why it works in my browser, but I can't ping it and why it works at home, but not at the office and that my coworker has a varying mileage.
It doesn't work in Azure either, which is even weirder, since all subdomains are registered in a DNS within a "proper" domain.
|
|
|
|
|
If the subdomains are also located on different subnets things get more hairy than a Minoxidil spill.
Running things local, all should work with the host file entries for 'real' domains... <client>.myapp and <client>.myappservice is probably what I would pick.
I think maybe there is confusion about the routing happening server-side vs client?
Which really just depends on the code. If the code to hit the service is c# server-side vs something like an inline json call from js, then which DNS resolution (and which hosts file, client v server) is getting used would be different.
|
|
|
|
|
Hmm, localhost is not technically a domain name, so I guess that is why it is elephanting when trying to resolve a sub domain from it.
Two things I can think of to try:
1. use sub.127.0.0.1:1234 (or possibly sub."127.0.0.1":1234
2. add sub.localhost to your hosts file. (pointing to 127.0.0.1 or localhost)
Good luck
|
|
|
|
|
RainHat wrote: so I guess that is why it is elephanting when trying to resolve a sub domain from it But only under specific (unknown) circumstances, like being at the office or having a VPN.
I've thought about the hosts file, but that won't explain why it works in my browser, but I can't ping it and why it works at home, but not at the office and that my coworker has a varying mileage.
It doesn't work in Azure either, which is even weirder, since all subdomains are registered in a DNS within a "proper" domain.
|
|
|
|
|
When you say you cannot ping it, do you mean you get no response or you get no name resolution?
Try powershells from the machines where the app is running if you can...
Test-NetConnect <ip or fqdn> -p <port> ... I may be off on some of that syntax.
|
|
|
|
|
From comments at top of hosts file:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
If I add a line to hosts file:
127.0.0.2 sub.localhost
then I can do:
>ping sub.localhost
Pinging sub.localhost [127.0.0.2] with 32 bytes of data:
Reply from 127.0.0.2: bytes=32 time<1ms TTL=128
Mircea
|
|
|
|
|
I've thought about the hosts file, but that won't explain why it works in my browser, but I can't ping it and why it works at home, but not at the office and that my coworker has a varying mileage.
It doesn't work in Azure either, which is even weirder, since all subdomains are registered in a DNS within a "proper" domain.
|
|
|
|
|
I think at least some browsers (Chrome, I'm looking at you!) have their own DNS resolver. VPN adds another level of weirdness and anyway localhost is not a valid domain name. Are you trying to solve all the possible interactions between these parts or you just want your app to work? If it's the first one, I'd like to hear the result, maybe in an article or tip here. If it's the second, just add a line to your hosts file. It has the highest priority in the DNS resolving order[^] and it just works.
Mircea
|
|
|
|
|
I think your workplace might have some dodgy network group policies/filters.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
modified 3hrs 20mins ago.
|
|
|
|
|
I'm suspicious of that too, especially with new AI network monitors/thwarters... But it would be super weird for them to muck with overriding the hosts file though?
|
|
|
|
|
I amended my comment to include group policies, which can do strange things to a machine.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
That's true... and which domain you are logging onto and whether you're "inhouse" or ingressing through a VPN or something could change which get applied. It could send you to different DNS servers (to help hide internal resources in domains that were more "edge"-closer to DMZ).
|
|
|
|
|
The only difference is a different Wi-Fi (shared with other tenants).
We don't have a work network, domain controller, etc.
|
|
|
|
|
Well I guess the good news is that simplifies the situation considerably.
The bad news is I have no idea what your next troubleshooting move should be.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|